iOS竖屏app,个别页面横屏处理

横屏设置

一、设置ViewControll

//支持旋转
- (BOOL)shouldAutorotate{
  return NO;
}

//支持的方向
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAllButUpsideDown;
}

 //一开始的方向
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
    return UIInterfaceOrientationLandscapeRight;
 }

二、自己维护横竖屏状态

建议写在viewWillAppear、viewWillDisappear里边
//进入页面时,将页面设置成横屏
[SupportedInterfaceOrientations sharedInstance].orientationMask = UIInterfaceOrientationMaskLandscape;

//退出页面时候,将页面设置成竖屏
[SupportedInterfaceOrientations sharedInstance].orientationMask = UIInterfaceOrientationMaskPortrait;

三、设置AppDelegate

- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    //返回当前屏幕状态
    return [SupportedInterfaceOrientations sharedInstance].orientationMask;
}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容