屏幕旋转 iOS7 iOS8 通用版
2015-09-18 11:41
337 查看
第一 presentViewController模式
vc的方向是vc自己管理的
第二 pushViewController模式
vc的方向是navigationController管理的
系统调用navigationController的方向适配
vc设置的不起作用 故添加分类
但是 但是 如果navigationController 是放在 TabBarController中的那么
vc的方向是TabBarController管理的
系统调用系统调用TabBarController的方向适配
vc设置的不起作用 故添加分类
现在需求是:个别屏幕横屏
基类做支持横屏处理 (自己写)
需要横屏处理的 添加
vc中如果需要状态栏转动的
注意 方向保持一致!方向保持一致!方向保持一致!
然后 iOS7下一切正常 iO8下各种不顺
问题一 push 后 pop回来界面没竖过来
返回前
问题二 状态栏横屏隐藏了
1、didFinishLaunchingWithOptions:中添加如下方法
(为啥 我也不知道 但是就是可以了 知道的求告知)
2、在plist文件中将 View controller-based status bar appearance 设置为NO
OK 大功告成
[self presentViewController:vc animated:YES completion:nil];
vc的方向是vc自己管理的
第二 pushViewController模式
[self.navigationController pushViewController:vc animated:YES];
vc的方向是navigationController管理的
系统调用navigationController的方向适配
vc设置的不起作用 故添加分类
@implementation UINavigationController (Rotation) - (BOOL)shouldAutorotate { return [self.topViewController shouldAutorotate]; } - (NSUInteger)supportedInterfaceOrientations { return [self.topViewController supportedInterfaceOrientations]; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return [self.topViewController preferredInterfaceOrientationForPresentation]; }
但是 但是 如果navigationController 是放在 TabBarController中的那么
vc的方向是TabBarController管理的
系统调用系统调用TabBarController的方向适配
vc设置的不起作用 故添加分类
- (BOOL)shouldAutorotate { return [self.selectedViewController shouldAutorotate]; } - (NSUInteger)supportedInterfaceOrientations { return [self.selectedViewController supportedInterfaceOrientations]; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return [self.selectedViewController preferredInterfaceOrientationForPresentation]; }
现在需求是:个别屏幕横屏
基类做支持横屏处理 (自己写)
需要横屏处理的 添加
- (BOOL)shouldAutorotate { return NO; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscapeRight; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationLandscapeRight; }
vc中如果需要状态栏转动的
[[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationLandscapeRight animated:NO];
注意 方向保持一致!方向保持一致!方向保持一致!
然后 iOS7下一切正常 iO8下各种不顺
问题一 push 后 pop回来界面没竖过来
返回前
[[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationPortrait animated:NO];
问题二 状态栏横屏隐藏了
1、didFinishLaunchingWithOptions:中添加如下方法
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone]; [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
(为啥 我也不知道 但是就是可以了 知道的求告知)
2、在plist文件中将 View controller-based status bar appearance 设置为NO
OK 大功告成
相关文章推荐
- IOS折线图
- iOS开发-截获html按钮点击事件,实现js调用native代码
- iOS9 适配教程
- IOS项目中使用CocoaPods管理依赖库
- <一>Copy和mutableCopy——iOS开发的疑惑
- iOS 9 Bitcode新问题集成第三方解决方案
- IOS动态类型isKindOfClass, isMemberOfClass
- 关于nagios监控系统添加主机和服务脚本
- IOS9 未受信任的企业级开发者 没有信任按钮 解决
- IOS动画相关知识
- 思科3750_IOS批量升级
- ios8/sdk8/xcode6/iphone6(+)适配
- 七款Debug工具推荐:iOS开发必备的调试利器
- ios 开发日记 9 - 升级xcode7报错
- iOS开发-常用第三方开源框架介绍
- iOS 9 适配系列教程
- iOS 9 错误解决方法
- iOS9适配
- iOS Crash文件的解析(一)
- iOS 一个控件无法显示出来的原因