iOS6的控制屏幕旋转技巧
2012-12-18 15:48
405 查看
在iOS5.1 和 之前的版本中, 我们通常利用 shouldAutorotateToInterfaceOrientation: 来单独控制某个UIViewController的旋屏方向支持,比如:
![](https://oscdn.geek-share.com/Uploads/Images/Content/2015036/fddc48d070bbafae23533bf575b1d281.jpg)
但是在iOS6中,这个方法被废弃了,使用无效。
shouldAutorotateToInterfaceOrientation:
Returns a Boolean value indicating whether the view controller supports the specified orientation. (Deprecated in iOS 6.0. Override the supportedInterfaceOrientations andpreferredInterfaceOrientationForPresentation methods instead.)
实践后会发现,通过supportedInterfaceOrientations的单独控制是无法锁定屏幕的。
![](https://oscdn.geek-share.com/Uploads/Images/Content/2015036/da1a8d8576691c9d33a08418b532e743.jpg)
多次实验后总结出控制屏幕旋转支持方向的方法如下:
子类化UINavigationController,增加方法。
![](https://oscdn.geek-share.com/Uploads/Images/Content/2015036/da8e69384b1d86ec619541179c1ef5bd.jpg)
并且设定其为程序入口,或指定为 self.window.rootViewController
随后添加自己的view controller,如果想禁止某个view controller的旋屏:(支持全部版本的控制)
![](https://oscdn.geek-share.com/Uploads/Images/Content/2015036/ae237ce36c91a6dd5b1b8bd86664da01.jpg)
如果想又开启某个view controller的全部方向旋屏支持:
![](https://oscdn.geek-share.com/Uploads/Images/Content/2015036/fbb07c859b81fbaeaa0e48cdb4920cf9.jpg)
从而实现了对每个view controller的单独控制。
顺便提一下,如果整个应用所有view controller都不支持旋屏,那么干脆:
![](https://oscdn.geek-share.com/Uploads/Images/Content/2015036/9b6ca8a5008ba54befe5704a6ecaf044.jpg)
来源:移动平台碎碎念的博客
![](https://oscdn.geek-share.com/Uploads/Images/Content/2015036/fddc48d070bbafae23533bf575b1d281.jpg)
但是在iOS6中,这个方法被废弃了,使用无效。
shouldAutorotateToInterfaceOrientation:
Returns a Boolean value indicating whether the view controller supports the specified orientation. (Deprecated in iOS 6.0. Override the supportedInterfaceOrientations andpreferredInterfaceOrientationForPresentation methods instead.)
实践后会发现,通过supportedInterfaceOrientations的单独控制是无法锁定屏幕的。
![](https://oscdn.geek-share.com/Uploads/Images/Content/2015036/da1a8d8576691c9d33a08418b532e743.jpg)
多次实验后总结出控制屏幕旋转支持方向的方法如下:
子类化UINavigationController,增加方法。
![](https://oscdn.geek-share.com/Uploads/Images/Content/2015036/da8e69384b1d86ec619541179c1ef5bd.jpg)
并且设定其为程序入口,或指定为 self.window.rootViewController
随后添加自己的view controller,如果想禁止某个view controller的旋屏:(支持全部版本的控制)
![](https://oscdn.geek-share.com/Uploads/Images/Content/2015036/ae237ce36c91a6dd5b1b8bd86664da01.jpg)
如果想又开启某个view controller的全部方向旋屏支持:
![](https://oscdn.geek-share.com/Uploads/Images/Content/2015036/fbb07c859b81fbaeaa0e48cdb4920cf9.jpg)
从而实现了对每个view controller的单独控制。
顺便提一下,如果整个应用所有view controller都不支持旋屏,那么干脆:
![](https://oscdn.geek-share.com/Uploads/Images/Content/2015036/9b6ca8a5008ba54befe5704a6ecaf044.jpg)
来源:移动平台碎碎念的博客
相关文章推荐
- iOS6的控制屏幕旋转技巧
- iOS6的控制屏幕旋转技巧
- iOS6下关于屏幕旋转的控制
- iOS6的旋屏控制技巧
- 总结iOS App开发中控制屏幕旋转的几种方式
- ios6 屏幕旋转总结[转]
- iOS6下屏幕旋转不响应以及使用Three20不旋转解决方案
- iOS 屏幕自动旋转控制
- iOS6的旋屏控制技巧
- iOS6的旋屏控制技巧
- iOS6下关于屏幕旋转的控
- iOS6与iOS7屏幕适配技巧
- UIInterfaceOrientation over iOS6 (应用旋转屏幕)
- 问题解决:iOS6下UIWebView嵌vedio标签播放视频屏幕不旋转
- 为什么IOS6屏幕无法旋转?
- IOS6 屏幕旋转 以及 旋转后的对应方法
- iOS6的旋屏控制技巧
- iOS6下屏幕旋转不响应以及使用Three20不旋转解决方案
- 问题解决:iOS6下shouldAutorotateToInterfaceOrientation不起作用,屏幕旋转同时支持iOS5和iOS6
- unity。。。完美简单解决靠鼠标在屏幕上的移动来控制相机水平,垂直旋转的c#脚本