iOS 控制屏幕横竖屏旋转

当需求有a页面支持横屏和竖屏外,其他都是竖屏
我现在的做法是:
1)AppDelegate.m
- (BOOL)shouldAutorotate {
   return NO;
}

- (NSUInteger)supportedInterfaceOrientations {
    
    return NO;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return  UIInterfaceOrientationPortrait;

}

2)A页面
- (BOOL)shouldAutorotate {
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations {
    
    return UIInterfaceOrientationMaskAll;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return  UIInterfaceOrientationPortrait;
}

 

// 注iOS9 

#if __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_9_0

- (NSUInteger)supportedInterfaceOrientations

#else

- (UIInterfaceOrientationMask)supportedInterfaceOrientations

#endif

{

    return UIInterfaceOrientationMaskPortrait;

}

 

posted @ 2015-11-17 20:47  zero_zql  阅读(452)  评论(0编辑  收藏  举报