IOS 4,5和6上对设备方向支持方法的变更
2013-10-13 11:40
531 查看
在IOS4,5上,设备的支持方向是每个view controller定义,默认是只能portrait,修改的话调用shouldAutorotateToInterfaceOrientation:方法,如:
在IOS 6以后,设备的支持方向,只能在rootviewcontroller(或Presentmodelviewcontroller上)设定支持方向,subview或者 child Viewcontroller根据rootviewcontroller来,
在rootviewcontroller里面调用:
如果是presentviewcontroller 会额外调用
preferredInterfaceOrientationForPresentation
注:如果要兼容4、5,则要实现shouldAutorotateToInterfaceOrientation方法,如上面所示代码。
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { return toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight; }
在IOS 6以后,设备的支持方向,只能在rootviewcontroller(或Presentmodelviewcontroller上)设定支持方向,subview或者 child Viewcontroller根据rootviewcontroller来,
在rootviewcontroller里面调用:
// New Autorotation support. - (BOOL)shouldAutorotate NS_AVAILABLE_IOS(6_0); - (NSUInteger)supportedInterfaceOrientations NS_AVAILABLE_IOS(6_0); //(当shouldAutorotate返回YES时,调用第二个方法,设定支持方向)
如果是presentviewcontroller 会额外调用
preferredInterfaceOrientationForPresentation
注:如果要兼容4、5,则要实现shouldAutorotateToInterfaceOrientation方法,如上面所示代码。
相关文章推荐
- 开源日历TimesSquare在iOS7下诡异渲染的解决办法
- TigerDLNA for ios 集成Tlplayer
- TigerDLNA for ios 集成Tlplayer
- 获得当前运行的设备上的 ios版本号
- Nagios部署手记
- 在MacOS和iOS系统中使用OpenCV
- IOS Socket使用大全
- iOS6的旋屏控制技巧
- iOS 4层结构(iOS技术概要)—— Cocoa Touch 层(一)
- 杂记
- iOS学习1:#pragma mark
- xen-4.1.2 编译minios
- 【OC】IOS多线程之NSoperation和GCD的比较
- IOS Block代码块的简单使用
- IOS CoreData 使用(二)
- IOS CoreData 使用 (一)
- 使用xmodem方式恢复IOS
- ios 手势 事件 全
- 关于nagios监控远程服务器对服务器性能影响的测试
- IOS CoreText.framework --- 基本用法