于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

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

什么时候rootViewController至tabbarController时刻,控制屏幕旋转法的更多相关文章

  1. Android -- 距离感应器控制屏幕灭屏白屏

    权限                                                                                             <u ...

  2. Cocos2D-x权威指南:通过节点控制屏幕中的全体渲染对象

    本节,已经能够利用我们眼下所学的知识做出一些有趣的东西.之前已经说过,CCNode类没有贴图,也就是说在屏幕上单独建立一个节点是没有不论什么效果的,可是能够通过这个"无形"的节点来 ...

  3. qt事件过滤器的使用(可以用于控制屏幕背光等)

    在嵌入式qt项目中,有时并不需求屏幕一直亮着,需要一段时间不操作时,将屏幕背光关掉,以达到节能的目的: 在qt项目中,可以通过重写事件过滤器来实现屏幕操作的检测,加上定时器的时间控制,可以实现指定时间 ...

  4. iOS 控制屏幕旋转

    在你想支持横竖屏的viewController里面重写两个方法: 1 2 3 4 5 6 7 8 9 10 11 // 支持设备自动旋转 - (BOOL)shouldAutorotate {      ...

  5. Flutter控制屏幕旋转

    特定页面旋转屏幕很简单: SystemChrome.setPreferredOrientations([ ... ]); 数组中是您要支持的屏幕方向. 如果想在特定页面固定横屏, 您可以这样写: @o ...

  6. iOS6的旋屏控制技巧

    在iOS5.1 和 之前的版本中, 我们通常利用 shouldAutorotateToInterfaceOrientation: 来单独控制某个UIViewController的旋屏方向支持,比如: ...

  7. iOS屏幕旋转 浅析

    一.两种orientation 了解屏幕旋转首先需要区分两种orientation 1.device orientation 设备的物理方向,由类型UIDeviceOrientation表示,当前设备 ...

  8. UIInterfaceOrientation over iOS6 (应用旋转屏幕)

      typedef NS_ENUM(NSInteger, UIInterfaceOrientation) { UIInterfaceOrientationUnknown = UIDeviceOrien ...

  9. iOS学习笔记(3)— 屏幕旋转

    一.屏幕旋转机制: iOS通过加速计判断当前的设备方向和屏幕旋转.当加速计检测到方向变化的时候,屏幕旋转的流程如下: 1.设备旋转时,系统接收到旋转事件. 2.系统将旋转事件通过AppDelegate ...

随机推荐

  1. 在JBuilder8中使用ANT

    在JBuilder8中使用ANT                                                            作者:翁驰原    在JBuilder8中,Ap ...

  2. RH033读书笔记(9)-Lab 10 Understanding the Configuration Tools

    Lab 10 Understanding the Configuration Tools Sequence 1: Configuring the Network with system-config- ...

  3. JAVA 公众微信的开放源码项目管理合作伙伴招募的版本号

    大家好:       jeecg开源社区.现在正在进行"JAVA 开放源码的版本号项目微信公共账号"工作,有兴趣的朋友一起參与. 截止时间:20140510 採用技术: 1. JE ...

  4. [原创].NET 分布式架构开发实战之三 数据访问深入一点的思考

    原文:[原创].NET 分布式架构开发实战之三 数据访问深入一点的思考 .NET 分布式架构开发实战之三 数据访问深入一点的思考 前言:首先,感谢园子里的朋友对文章的支持,感谢大家,希望本系列的文章能 ...

  5. 90社交网络的行为报告后:不拒绝陌生人,TFBOYS作为一个喜爱

    依据腾讯QQ与易观合作的<2014中国90后青年调查报告>,盘点了90后使用社交网络的行为习惯. 相比于70.80后.90后更愿意在社交媒体上公布自己照片.状态,且更愿意在即时通讯中加陌生 ...

  6. php中国的垃圾问题

    header这条线加,这是解决中国乱码的问题. 版权声明:本文博主原创文章,博客,未经同意不得转载.

  7. ExtJS学习笔记:定义extjs类别

    类的定义 Ext.define('Cookbook.Vehicle', { Manufacturer: 'Aston Martin', Model: 'Vanquish', getDetails: f ...

  8. 使用方便 正则表达式grep,sed,awk(一)

    一些无稽之谈: 对于正则表达式,永远似了解不明白,看到一些代码,脚本定期,awk,sed.心里总有点虚.主要是记不住.平时又没怎么用,也就没总结了. 如今有空,决定总结一下,顺便克服一下看到shell ...

  9. UIBezierPath 和 CAShapeLayer 绘画图纸

    五角大楼画一个小圆圈戴: - (void)drawPentagon{ //(1)UIBezierPath对象 UIBezierPath *aPath = [UIBezierPath bezierPat ...

  10. 华夏互联与逐浪CMS旗下三款软件获著作权登记

     北京时间2014年7月24日消息: 上海逐一软件科技公司长下三款软件通过中国知识产权局登记,当中包含全新的CMS2 x2.0主产品.移动门户管理系统.云台管理系统. 除主产品CMS2 x2.0( ...