转屏
来源:互联网 发布:鲜花淘宝店 编辑:程序博客网 时间:2024/05/23 12:43
症状:
willRotateToInterfaceOrientation在ios5地下不执行,ios6 地下没事儿。
原因:
与 add subview 有关
具体原因,之前改了一段代码,详细参看,弹出键盘的怪事儿。导致页面结构变了。
结论:
看来ios 5 和 6 ,关于willRotateToInterfaceOrientation 是否执行,还是有点差别的。
解决办法,比较hack,
http://stackoverflow.com/questions/8016479/ios-5-willrotatetointerfaceorientationduration-not-called-when-first-loading-c
Since I'm pressed for time I've had to work around this odd behaviour and manually call the orientation methods in viewDidLoad. This is a bit of a hack but it's working fine so far.
In viewDidLoad I added this:
if ( SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"5.0") ) { UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation]; [self willRotateToInterfaceOrientation:interfaceOrientation duration:0.2f];}
I've then added this in a common header file:
// iOS Version Checking#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
I got the iOS version checking defines from an answer to this question on SO.
Since this is a bit of a hack I will leave this question unanswered for a little while just in case someone else finds a better way.
http://stackoverflow.com/questions/1516268/willrotatetointerfaceorientation-not-being-called
这个讲得也很好,虽然我已经知道了。
Is this views viewController a subview of some other root view controller thats not a navigation controller? if so then the call does not propagate to the subviews controller, so that might be why your view isnt rotating.- 转屏
- 转屏
- 转屏
- 转屏
- iOS转屏
- iOS转屏
- IOS 转屏
- iOS转屏
- IOS 自动(手动)转屏
- IOS开发 webView 播放加速 转屏
- i os 转屏API的改变
- android 转屏 onConfigurationChanged 不会执行的问题
- 关于activity转屏 上一个activity onDestory的问题
- android转屏,切换屏幕,横竖屏(onConfigurationChanged)会重新 OnCreate 的解决方案
- android转屏,切换屏幕,横竖屏(onConfigurationChanged)会重新加载 OnCreate 的解决方案
- android转屏,切换屏幕,横竖屏(onConfigurationChanged)会重新 OnCreate 的解决方案
- 旧工程适配ios6和iphone5 之 适配ios6转屏
- IOS屏幕3.5寸和4寸屏幕适配 之 适配ios6转屏
- myeclipse svn 设置不需要提交的文件
- unity3d 屏幕截图多种写法
- COCOS2D-X UI组件
- Visual Studio遇到异常。这可能是由某个扩展导致的。
- ubuntu 自动加载ntfs分区
- 转屏
- 如何在cmd命令行中查看、修改、删除与添加环境变量 .
- 仪器TEST
- win7下用SetIpForwardEntry修改路由失败的问题
- linux 之assert学习
- Amber中做correlation map图
- 机房收费系统文档
- jquery效果2
- Android 搭建客户端手机和服务端的交互