你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS編程技術 >> iOS橫屏問題

iOS橫屏問題

編輯:IOS編程技術

首先解決橫屏問題
1.工程設置只支持豎屏

2.AppDelegate的window設置支持所有

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return UIInterfaceOrientationMaskAll;
}

3.UINavigationController或者BaseViewController只支持豎屏
(這樣保證了應用程序支持橫屏,而且平常的vc是豎屏,然後要橫屏的vc present出來)

- (BOOL)shouldAutorotate
{
    return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

4.播放器界面present出來,支持橫豎屏

-(BOOL)shouldAutorotate
{
    return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;
}

 

播放器界面present出來,支持橫屏

-(BOOL)shouldAutorotate
{
    return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}

//狀態欄設置ios7.0以上

-(void)playerViewDelegateSetStatusBarHiden:(BOOL)is_hiden
{
    self.stauts_bar_hiden = is_hiden;
    [self prefersStatusBarHidden];  //隱藏還是顯示
    //更新statusbar
    [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)]; //刷新狀態欄
}

- (BOOL)prefersStatusBarHidden
{
    return self.stauts_bar_hiden;
}
 
  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved