iPhone开发笔记(21)iOS 6旋转问题解决方法汇总
2013-06-16 13:09
846 查看
iOS 6的SDK改变了以往控制UIViewController的方式,为了兼容iOS 5和iOS 6,需要对代码进行必要的调整。因为每个应用的结构不一样,所以再这篇文章中,我只讲了我所遇到的UITabBarController+UINavigationController的应用结构。此外,我也在最后列出了一些情况的解决方法,如果本文的方法对你遇到的问题不起作用,那么可以试试列出的连接给出的解决方法。
1、在工程的设置界面将设备支持的旋转方向开关开启如下图:
2、设置window的rootViewController
在AppDelegate.h中
3、添加UITabBarController的Category
4、在需要开启自动旋转的UIViewController的.m文件中添加如下代码
5、其他情况的解决方法参考
http://stackoverflow.com/questions/12522903/uitabbarcontroller-rotation-issues-in-ios-6
1、在工程的设置界面将设备支持的旋转方向开关开启如下图:
2、设置window的rootViewController
在AppDelegate.h中
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ...... self.window.rootViewController = tabBarController; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; return YES; }
3、添加UITabBarController的Category
@implementation UITabBarController (Background) -(BOOL)shouldAutorotate { //这里我是首先从全局的角度设置自动旋转为NO,因为不需要每个UIViewController都自动旋转。 return NO; } - (NSUInteger)supportedInterfaceOrientations { //全局设置为 return UIInterfaceOrientationMaskPortrait; } @end @implementation AppDelegate
4、在需要开启自动旋转的UIViewController的.m文件中添加如下代码
//iOS 5以前的旋转控制方法 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { return ((interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown) && (interfaceOrientation != UIInterfaceOrientationLandscapeLeft) && (interfaceOrientation != UIInterfaceOrientationLandscapeRight)); } else { return YES; } } /iOS 6的旋转控制方法 - (BOOL)shouldAutorotate { return YES; } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskAllButUpsideDown; }
5、其他情况的解决方法参考
http://stackoverflow.com/questions/12522903/uitabbarcontroller-rotation-issues-in-ios-6
相关文章推荐
- iPhone开发笔记(21)iOS 6旋转问题解决方法汇总
- iPhone开发笔记(15)URL传参的问题和解决方法
- 个人在iOS开发过程中真机调试遇到的问题及解决方法 推荐
- 个人在iOS开发过程中真机调试遇到的问题及解决方法
- iphone 开发中使用zbar时遇到的几个典型问题解决方法。
- iOS错误汇总:解决Xcode iPhone工程变成了My Mac的问题
- 打开键盘遮住View的问题解决方法-IOS开发
- Xcode做ios开发时 message sent to deallocated instance问题的解决方法(gdb和lldb)
- iOS开发笔记[13/50]:解决SenTestingKit/SenTestingKit.h: No such file or directory问题
- 打开键盘遮住View的问题解决方法-IOS开发
- IOS开发各种问题解决方法记录
- iPhone开发中遇到的问题解决笔记
- 打开键盘遮住View的问题解决方法-IOS开发
- ios app开发时遇到的问题和解决方法教程
- iOS开发 UIimage旋转,得到旋转后的Image图片,解决imageView旋转,内部图片不跟着旋转问题
- ionic在开发ios系统微信时键盘挡住输入框的解决方法(键盘弹出问题)
- iOS开发:多人开发中从Git上面拉取新项目,当前Xcode不是最新版本情况下不显示模拟器的问题解决方法
- iOS开发之导航栏各种右滑返回失效的解决方法汇总
- IOS开发键盘弹出时遮住输入框的问题的一种解决方法。
- Xcode 9下适配iPhoneX导致iOS 10不兼容问题的解决方法