iOS实现单个页面强制横屏

来源:互联网 发布:数据库处理流程图 编辑:程序博客网 时间:2024/05/19 12:38

iOS实现单个页面强制横屏


背景:我们公司的应用是不支持横屏的,但最近需求,让一个VR看房的页面,进去的时候就强制横屏.

实现很简单,其他页面的代码不用动(包括plist文件中的横竖屏选项,BaseNavigationController中也不需要修改),只需在需要横屏的页面实现下面几句代码即可

代码如下(实现右横屏),注意这个页面必须用present的方式推出.


- (BOOL)shouldAutorotate

{

return NO;

}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations

{

return UIInterfaceOrientationMaskLandscape;

}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation

{

return UIInterfaceOrientationLandscapeRight;

}


0 0