屏幕旋转 iOS7 iOS8 通用版
来源:互联网 发布:协同过滤推荐算法综述 编辑:程序博客网 时间:2024/04/30 15:50
第一 presentViewController模式
[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 大功告成
0 0
- 屏幕旋转 iOS7 iOS8 通用版
- IOS8中屏幕旋转问题解决
- ios7,ios8的屏幕适配
- ios7禁止屏幕旋转,强制竖屏
- iOS7、iOS8中的CGAffineTransformRotate、view的旋转方向问题
- IOS7 到IOS8 一个通用的横竖屏幕切换总结
- iOS7到iOS8 一个通用的横竖屏幕切换总结
- 在ios8中做的屏幕旋转功能
- 关于屏幕旋转设置:iOS5、iOS6及iOS7
- ios7、ios8中的UITableViewCellEditingStyle
- ios7 ios8 Notification
- registerForRemoteNotification iOS7 iOS8
- iOS7,iOS8,iOS9适配
- IOS 关于IOS8屏幕的强制旋转与新的特性
- IOS8 旋转的问题
- iOS8旋转屏
- iOS7与iOS8的比较
- iOS7适配,求iOS8文档
- 菜鸟的安卓实习之路----如何去掉listView滑动到其他布局底部的时候的阴影效果
- C++中*与&的区别
- codeforces 566F. Clique in the Divisibility Graph dp
- (2.1.2.7)ThreadPoolExecutor的应用和实现分析(中)—— 任务处理相关源码分析
- Java中解决中文乱码问题的一种方法
- 屏幕旋转 iOS7 iOS8 通用版
- 构造二叉树
- 教你验证一个文件夹下最多可以有多少个子文件夹
- poj1326
- 前端收集(前端学习资源)
- transform-origin CSS3 旋转
- 版本控制系统小结
- APACHE日志参数说明
- 内核导言之文件子系统概貌