爱程序网

iOS 9 强制横屏

来源: 阅读:

首先在plist 文件中 Supported interface orientations 选项 只留下一个 portrait

屏幕强制横屏 使用以下代码

self.navigationController.view.transform = CGAffineTransformMakeRotation(M_PI/2);

    self.navigationController.view.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);

    [[UIApplication sharedApplication] setStatusBarHidden:YES];

返回正常竖屏显示时(在viewWillDisappear中添加)

self.navigationController.view.transform = CGAffineTransformIdentity;

    self.navigationController.view.frame = [UIScreen mainScreen].bounds;

    [[UIApplication sharedApplication] setStatusBarHidden:NO];

 

UIApplication 中 statusBarOrientation 属性在ios 9 中已经不能用了 项目中需要横屏的页面直接隐藏了状态栏。

 

资源转载自:http://www.cnblogs.com/jiackyan/p/3382734.html

关于爱程序网 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助