UINavigationController、UITabBarController 支持屏幕自动旋转问题
来源:互联网 发布:clint eastwood 知乎 编辑:程序博客网 时间:2024/05/19 01:10
写了一篇关于屏幕强制旋转的文章,可是有人跟我反应说没成功,状态栏依旧没有改变。原因是他的rootViewController是UINavigationController跟UITabBarController混合使用的。
因为UINavigationController跟UITabBarController也是UIViewController,所以会覆盖其子页面的旋转方法。
解决方法:添加以下类
//// UINavigationController+Rotation_IOS6.m// djy//// Created by SuFuTe on 14/12/30.// Copyright (c) 2014年 SuFuTe. All rights reserved.//#import "UINavigationController+Rotation_IOS6.h"@implementation UINavigationController (Rotation_IOS6)-(BOOL)shouldAutorotate { NSLog(@"UINavigationController 100"); // 不想其子页面支持旋转, 可直接返回 NO return YES;}-(NSUInteger)supportedInterfaceOrientations { NSLog(@"UINavigationController 200"); return [[self.viewControllers lastObject] supportedInterfaceOrientations];}- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { NSLog(@"UINavigationController 300"); return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];}@end
//// UITabBarController+Rotation_IOS6.m// djy//// Created by SuFuTe on 14/12/30.// Copyright (c) 2014年 SuFuTe. All rights reserved.//#import "UITabBarController+Rotation_IOS6.h"@implementation UITabBarController (Rotation_IOS6)-(BOOL)shouldAutorotate { NSLog(@"UITabBarController 100"); // 不想其子页面支持旋转,可直接返回 NO return YES;}-(NSUInteger)supportedInterfaceOrientations { NSLog(@"UITabBarController 200"); //return UIInterfaceOrientationMaskPortrait; return [[self.viewControllers lastObject] supportedInterfaceOrientations];}- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { NSLog(@"UITabBarController 300"); //return UIInterfaceOrientationPortrait; return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];}@end
AppDelegate.m中导入头文件
#import "UINavigationController+Rotation_IOS6.h"#import "UITabBarController+Rotation_IOS6.h"
-(BOOL)shouldAutorotate;-(NSUInteger)supportedInterfaceOrientations;-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation;
0 0
- UINavigationController、UITabBarController 支持屏幕自动旋转问题
- ios6.0 UINavigationController、UITabBarController 支持屏幕自动旋转问题
- 禁止屏幕旋转(不管UINavigationController和UITabBarController)
- 屏幕旋转自动问题
- 屏幕自动旋转的问题
- 屏幕自动旋转的问题
- 继承UINavigationController的问题----UITabBarController
- UINavigationController+UITabBarController+内容遮挡问题
- iOS5,iOS6,iOS7中UITabBarController,UINavigationController等界面中的旋转问题总结
- iOS5,iOS6,iOS7中UITabBarController,UINavigationController等界面中的旋转问题总结
- iOS5,iOS6,iOS7中UITabBarController,UINavigationController等界面中的旋转问题总结
- IOS iOS5,iOS6,iOS7中UITabBarController,UINavigationController等界面中的旋转问题总结
- iOS5,iOS6,iOS7中UITabBarController,UINavigationController等界面中的旋转问题总结
- iOS5,iOS6,iOS7中UITabBarController,UINavigationController等界面中的旋转问题总结
- iOS5,iOS6,iOS7中UITabBarController,UINavigationController等界面中的旋转问题总结
- UITabBarController旋转问题
- UINavigationController,UITabBarController
- UINavigationController, UITabBarController
- 醉了,mysql的删除居然变得这么麻烦 delete from table where id in()
- 通过Gearman实现MySQL到Redis的数据同步
- oracle12c安装时出错:[INS-30131] 执行安装程序验证所需的初始设置失败。
- CListCtrl控件选中并高亮显示
- DedeCMS自学教程10:文档内容末尾加“当前文档页面地址”和“转载说明”
- UINavigationController、UITabBarController 支持屏幕自动旋转问题
- 待机界面-点击亮度调节快捷键,在LCD亮度渐变时有闪屏现象
- 为什么会有extern "C"这样的规定?
- 如何debug makefile文件
- ecshop中点击分类时如果有子分类显示子分类,没有的话就不显示
- 安全加密方案
- iOS 17个常用代码整理
- LitePal学习总结 (五)
- php优化的小细节2