iOS横竖屏的问题
来源:互联网 发布:手机淘宝 发文件 编辑:程序博客网 时间:2024/06/05 08:21
最近做的项目要求大部分只支持竖屏,只有少部分页面才能横竖屏切换。
1.如果根控制器是UITabBarController,需要创建一个UITabBarController的子类,并重写这几个方法
-(BOOL)shouldAutorotate
{
return [self.selectedViewController shouldAutorotate];
}
#if __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_9_0
- (NSUInteger)supportedInterfaceOrientations
#else
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
#endif
{
return [self.selectedViewController supportedInterfaceOrientations];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return [self.selectedViewController preferredInterfaceOrientationForPresentation];
}
2.如果根控制器是UINavigationController,需要创建UINavigationController子类,并重写这几个方法
-(BOOL)shouldAutorotate
{
return [[self.viewControllers lastObject] shouldAutorotate];
}
#if __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_9_0
- (NSUInteger)supportedInterfaceOrientations
#else
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
#endif
{
return [[self.viewControllers lastObject] supportedInterfaceOrientations];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
}
3.之后在每个控制器里根据需求来重写下面的方法如:
// 不支持设备旋转
- (BOOL)shouldAutorotate
{
return false;
}
//支持的方向
-(UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
- iOS横竖屏的问题
- ios横竖屏问题
- iOS横竖屏问题
- 横竖屏切换问题ios
- iOS横竖屏转换问题
- iOS 获取横竖屏的方法和问题
- ios播放器横竖屏切换的问题
- ios 横竖屏的使用
- iOS 的横竖屏锁定
- iOS的横竖屏切换
- iOS 屏幕横竖屏切换问题
- Android横竖屏的问题
- zxing 横竖屏的问题
- IOS下的横竖屏切换研究
- iOS 横竖屏走的方法
- iOS屏幕(UIViewController)旋转的横竖屏
- iOS 9的屏幕横竖屏设置
- ios 控制页面的横竖屏
- Android 解决Only the original thread that created a view hierarchy can touch its views异常
- leetcode--Populating Next Right Pointers in Each Node II
- 欢迎使用CSDN-markdown编辑器
- 直播预告 | 极限挑战:在最短时间内定位性能瓶颈!
- [P1896][SCOI2005]互不侵犯King
- iOS横竖屏的问题
- 栈的应用---------有关字符串的输入
- 封装自己的js组件
- 数据结构实验之排序四:寻找大富翁
- Linux进程相关命令-ps、kill
- 【2017多校第二场】HDU 6075 Questionnaire【思维】
- Eclipse代码格式模板导入
- leetcode--Binary Tree Postorder Traversal
- J-02. 向导快速设置 ❀ 瞻博 (Juniper) 防火墙