- 浏览: 77767 次
- 性别:
- 来自: 武汉
最新评论
-
woainike:
hhb19900618 写道兄弟 我没理解 _subThree ...
performSelectorOnMainThread 和detachNewThreadSelector区别. -
hhb19900618:
兄弟 我没理解 _subThreed = [NSThread ...
performSelectorOnMainThread 和detachNewThreadSelector区别. -
woainike:
hhb19900618 写道你好 我想问一下: //下载结束, ...
performSelectorOnMainThread 和detachNewThreadSelector区别. -
hhb19900618:
你好 我想问一下: //下载结束,刷新 [self pe ...
performSelectorOnMainThread 和detachNewThreadSelector区别.
OS6正式版发布当天博主我就更新了,随后也更新了对应的XCode以及iOS SDK,更新到了4.5 (4G182)。然后更新原有4.4 iOS5 SDK的项目,目前最主要的发现就是iOS6对于app屏幕朝向支持以及自动旋屏时的处理方式的变动。
简而言之就是iOS6下的
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { return UIInterfaceOrientationIsLandscape(toInterfaceOrientation); }
这个不会再被调用,取而代之的是这俩个组合:
- (BOOL)shouldAutorotate { return YES; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; }
当然,为了保持对旧版本系统行为的兼容性,不要删掉不用的那个调用。另外还有一个这个preferred朝向也可以加上
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationLandscapeRight; }
当我替换完这俩个操作后尝试运行app,发现会报如下的异常:
Terminating app due to uncaught exception ‘UIApplicationInvalidInterfaceOrientation’, reason: ‘Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES’
经查发现导致此异常的原因是app再info.plist中指定的屏幕朝向没有portrait,也就是只支持landscape横屏,但是app集成了Game Center应用,而Game Center触发的登录界面只支持竖屏显示(这点有开发帐号的朋友可以到苹果官方开发论坛上看下,有个苹果官方人员发的证实贴,由于现阶段的NDA就不转了),解决这个问题的方法就是再应用的delegate中加入如下回调:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) return UIInterfaceOrientationMaskAll; else /* iphone */ return UIInterfaceOrientationMaskAllButUpsideDown; }
这样就可以再不改变info.plist中的设置的前提下,兼容gamecenter的竖屏登录问题。
顺带一提,对于Game Center排行等界面的旋屏朝向限制方法:
@implementation GKLeaderboardViewController(Landscape) - (BOOL)shouldAutorotate { return YES; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscapeRight|UIInterfaceOrientationMaskLandscapeLeft; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationLandscapeRight; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationIsLandscape(interfaceOrientation); } @end
这个时候确实感到objective-c的category之方便啊,呵呵。
再有一个问题就是window的rootViewController问题,在iOS6下,必须通过setRootViewController指定根视图控制器,否则didFinishLaunchingWithOptions结束后会报必须指定根视图控制器的错误。网上看到有人提到在iOS6下addSubview的方法将不再起作用,而必须使用指定rootViewController的方式,而我实际测试时还发现了另外一个小问题,就是在切换view的时候,比如用MPMoviePlayerViewController播放intro视频,然后再切换到游戏OpenGL视图时的addSubView和removeFromSuperview的交替会出现一些奇怪的GL视图朝向错误问题,而且也找不到任何相关旋屏的log输出,最后发现只要是用了iOS6的SDK就必须调用setRootViewController,iOS6以前的系统还需要额外调用addSubview,这样就不会出现那种切换view后的诡异问题了,至少我目前找到的解决方法是这样,不知是否另有玄机?附上改后的根据系统版本号执行不同切换方式的简单代码:
if ([[UIDevice currentDevice].systemVersion floatValue]<6.0) { // 高兼容性的做法 [self.window setRootViewController:self.viewController]; [self.window addSubview:self.viewController.view]; } else { [self.window setRootViewController:self.viewController]; } [self.viewController.view setNeedsDisplay];
最后再爆料一个屏幕初始朝向的问题,我们知道,设定屏幕初始朝向的方法是再info.plist中指定Initial interface orientation项,而我发现无论怎么设置,横屏都只能以landscape-left的方式启动,就是按钮在左边那种,不管是升级的旧项目,还是新建的项目均是如此,不知是否有朋友也遇到了这个问题?
发表评论
-
个人网站建立了,后期数据移步www.rbbtsn0w.com
2013-09-04 23:00 1374个人网站建立了,后期数据移步www.rbbtsn0w.com -
UIRefreshControl for Tableview or TableViewController
2013-06-26 00:06 1226@interfaceViewController ( ... -
About search your address on MKMapView.
2013-06-09 22:47 1361When you have address it's a s ... -
针对UIBarButtonItem 下面的backbutton,一个很简单自定义方式。
2013-06-06 22:23 1227如果只需要用图片替换原来的back button,不需要里面 ... -
Custom your view and load in code. It's difference viewcontrolller.
2013-03-20 15:52 828You need to load it using t ... -
Xcode, git and .DS_Store
2012-11-28 21:23 1403On trying to merge two git b ... -
git for windows
2012-11-21 10:51 1148bulid 环境 scp 提交的命令 ... -
无聊的测试。release后还需要removeallobjects?
2012-11-14 16:42 1739#import <UIKit/UIKit.h> ... -
cookie观察
2012-10-24 12:51 794NSHTTPCookieStora ... -
Mac os 命令
2012-09-22 11:43 767打开终端输入命令:defaults writ ... -
DisMiss Keyboard,自定义的工具类
2012-09-17 17:15 1162// // Keyboard.h // Cust ... -
实效API
2012-08-02 12:04 1853iOS6 之后 presentModa ... -
APP 图片比例和名称规范 ,最新iPhone5比例
2012-07-25 21:10 2795从icon说起命名方法,举例 iPhone & ... -
The Icon and Default Images
2012-07-25 21:10 800The icon.png imag ... -
xcode的各个版本的下载地址
2012-03-29 10:51 1902现在进入apple的developer网站,默认只提供最 ... -
越狱开发
2012-03-23 18:07 0环境需要: Mac OS X 1 ... -
杂乱的草稿纸Cloud
2012-03-21 14:06 0NSAutoreleasePool *pool = [[ ... -
IP Address
2012-03-14 17:39 972再来一篇,获取本地IP,三种方法: (1)在Day ... -
Copy Functions
2012-03-06 15:47 1235Copy Functions 在一般 ... -
UILabel 中Line Breaks属性.
2012-02-29 14:16 1972Clip Character Wrap Wor ...
相关推荐
全套的ios图标,png 64x64像素 适合b/s开发使用,如管理系统开发
ios项目适配ios6 ios7 注重页面属性的修改。
iphone越狱 ios6很好用 ios6.1.6也可以 ios6系列越狱
iOS 6 基础教程(Beginning iOS 6 Development )随书源码下载
手把手教你把你的ios6的设备变成ios7
彩虹猫高仿iOS6.mtz
iOS6可玩的滚动的天空,ipa软件包,旧版软件
Beginning iOS 6 Development Exploring the iOS SDK ios开发基础教程
对于某些用户来说,越狱可能只是为了能够装破解盗版软件。其实越狱真正的意义并非如此,而是能够打破苹果系统自身的桎梏,安装各种系统类的插件,实现IOS系统自身无法实现的功能,让iPhone变得更强大。
这是 iOS 6 编程实战 全书的代码。。我找不到这本书的免费电子文档。。如果有找到这本书的电子文档的朋友请发我一份吧
IOS6状态栏透明
ios6 越狱
iOS6编程 pdf 中文 全部 全部章数都有 扫描版
IOS 里 水滴效果的刷新控件 已测试IOS 6 ,7, 64位上运行 OK 5 的没测试
ios7 ios6(3.5inch,4inch)适配demo。 内容不多,思路简单使用。
IOS7呈现IOS6自带水滴刷新效果,还有一个加载提示效果的东东
苹果越狱助手,ios6系统越狱工具。大家欢迎下载使用。
泰拉瑞亚 iOS6旧版
iOS 6 Programming Cookbook