于ios6后,ios系统改变了屏幕旋转的方法,假设您想将屏幕旋转法,在需求rootvc里面制备,例如

UIViewController *viewCtrl = [[UIViewController alloc] init];
UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:viewCtrl];
if ([window respondsToSelector:@selector(setRootViewController:)]) {
self.window.rootViewController = navCtrl;
} else {
[self.window addSubview:navCtrl.view];
}

当root为nav时,你要建立一个nav的子类,进行改动,假设是vc时,直接能够在vc里进行改动,网上已经有非常多的样例了,但假设是tabbar里面嵌套这非常多nav和vc,nav里又有vc我们要怎么弄呢,以下是我调研的一些方法,就是用几个category对nav和tabbarController进行类别的编写,让他们能够分别相应子视图的旋转方向

UITabBarController+autoRotate

@interface UITabBarController (autoRotate)

-(BOOL)shouldAutorotate;
- (NSUInteger)supportedInterfaceOrientations; @end #import "UITabBarController+autoRotate.h" @implementation UITabBarController (autoRotate) - (BOOL)shouldAutorotate {
return [self.selectedViewController shouldAutorotate];
}
- (NSUInteger)supportedInterfaceOrientations {
return [self.selectedViewController supportedInterfaceOrientations];
} @end

UINavigationController+autoRotate.h

@interface UINavigationController (autoRotate)

-(BOOL)shouldAutorotate;
- (NSUInteger)supportedInterfaceOrientations; @end @implementation UINavigationController (autoRotate) - (BOOL)shouldAutorotate {
return [self.visibleViewController shouldAutorotate];
} - (NSUInteger)supportedInterfaceOrientations {
return [self.visibleViewController supportedInterfaceOrientations];
} @end
UIViewController1.m

- (BOOL)shouldAutorotate {
return NO;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;;
}
UIViewController2.m - (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAll;
}

參考文章:IOS6屏幕旋转具体解释(自己主动旋转、手动旋转、兼容IOS6之前系统) , 在IOS应用中从竖屏模式强制转换为横屏模式 , http://stackoverflow.com/questions/12522903/uitabbarcontroller-rotation-issues-in-ios-6

版权声明:本文博主原创文章。博客,未经同意不得转载。

最新文章

  1. React之Froms
  2. linux 查看磁盘剩余命令
  3. Porter/Duff,图片加遮罩setColorFilter
  4. Java线程之CompletionService
  5. Python 中的 TK编程
  6. Go 接口转换的一个例子
  7. gulp+browserSync+nodemon 实现express 全端自动刷新的实践
  8. Eclipse选中变量名,相同变量都变色显示 的设置
  9. FZU 2170 花生的序列(动态规划)
  10. 关于SpringMVC中text/plain的编码导致的乱码问题解决方法
  11. [置顶] xamarin android自定义标题栏(自定义属性、回调事件)
  12. Python+selenium自动化测试中Windows窗口跳转方法
  13. ASP.NET machineKey的作用和使用方法
  14. Nginx FIND_CONFIG阶段
  15. LeetCode 883 Projection Area of 3D Shapes 解题报告
  16. 在VS 2010上搭建Windows Phone 7开发平台
  17. Hashing图像检索源码及数据库总结
  18. 分布式缓存设计:一致性Hash算法
  19. javascript获取网址参数
  20. 关于iOS UIWebView 加载网页,点击网页内某些控件导致 Application 'UIKitApplication:xxx.xxx.xxx' was killed by jetsam.

热门文章

  1. java多线程Future和Callable类的解释与使用
  2. jQuery 操作 input 之 checkbox
  3. [LeetCode62]Unique Paths
  4. 让Emeditor支持markdown编辑博客
  5. Java Enum使用演示样品枚举
  6. 浅谈web网站架构演变过程(转)
  7. SRM 590 DIV1
  8. poj 2762 Going from u to v or from v to u? (推断它是否是一个薄弱环节图)
  9. SQL Server数据库附加失败:错误5120和错误950
  10. Java泛型Restletclient