-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.navigationController.navigationBar.hidden = NO;
if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
SEL selector = NSSelectorFromString(@"setOrientation:");
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]];
[invocation setSelector:selector];
[invocation setTarget:[UIDevice currentDevice]];
int val = UIInterfaceOrientationLandscapeRight;
[invocation setArgument:&val atIndex:2];
[invocation invoke];
}
}
-(void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
self.navigationController.navigationBar.hidden = NO;
if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
SEL selector = NSSelectorFromString(@"setOrientation:");
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]];
[invocation setSelector:selector];
[invocation setTarget:[UIDevice currentDevice]];
int val = UIInterfaceOrientationPortrait;
[invocation setArgument:&val atIndex:2];
[invocation invoke];
}
}
- (BOOL)shouldAutorotate
{
return YES;
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
2.跳轉(zhuǎn)系統(tǒng)設(shè)置
1虫溜,如何跳到指定的設(shè)置界面遇绞,例如設(shè)置WiFi的時候,想直接跳到WiFi設(shè)置界面勾习。
在URL Types添加 一個叫prefs的URL Schemes
2.添加這段代碼(把下面的Bundle identifier替換為相應(yīng)的字段即可)
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=Bundle identifier"]];
可以直接打開對應(yīng)App的設(shè)置頁面
3.對應(yīng)的字段
蜂窩網(wǎng)絡(luò):prefs:root=MOBILE_DATA_SETTINGS_ID
VPN — prefs:root=General&path=Network/VPN
Wi-Fi:prefs:root=WIFI
定位服務(wù):prefs:root=LOCATION_SERVICES
個人熱點:prefs:root=INTERNET_TETHERING
關(guān)于本機:prefs:root=General&path=About
輔助功能:prefs:root=General&path=ACCESSIBILITY
飛行模式:prefs:root=AIRPLANE_MODE
鎖定:prefs:root=General&path=AUTOLOCK
亮度:prefs:root=Brightness
藍牙:prefs:root=General&path=Bluetooth
時間設(shè)置:prefs:root=General&path=DATE_AND_TIME
FaceTime:prefs:root=FACETIME
設(shè)置:prefs:root=General
鍵盤設(shè)置:prefs:root=General&path=Keyboard
iCloud:prefs:root=CASTLEiCloud
備份:prefs:root=CASTLE&path=STORAGE_AND_BACKUP
語言:prefs:root=General&path=INTERNATIONAL
定位:prefs:root=LOCATION_SERVICES
音樂:prefs:root=MUSICMusic
Equalizer — prefs:root=MUSIC&path=EQMusic
Volume Limit — prefs:root=MUSIC&path=VolumeLimit
Network — prefs:root=General&path=Network
Nike + iPod — prefs:root=NIKE_PLUS_IPOD
Notes — prefs:root=NOTES
Notification — prefs:root=NOTIFICATIONS_ID
Phone — prefs:root=Phone
Photos — prefs:root=Photos
Profile —prefs:root=General&path=ManagedConfigurationList
Reset — prefs:root=General&path=Reset
Safari — prefs:root=Safari
Siri — prefs:root=General&path=Assistant
Sounds — prefs:root=Sounds
Software Update — prefs:root=General&path=SOFTWARE_UPDATE_LINK
Store — prefs:root=STORET
witter — prefs:root=TWITTER
Usage — prefs:root=General&path=USAGE
Wallpaper — prefs:root=Wallpaper