关于IOS屏幕旋转的几个问题1.常规设置2.个别页面强制固定横竖屏
2015-06-17 11:26
826 查看
1.常规设置屏幕旋转 (Device Orientation || info.plist-----这两个地方的设置是同步的)
1)targets->General->Deployment Info->Device Orientation 直接勾选想要的设备定位全局属性
2)Supporting Files->Info.plist->Supported interface orientations 增删属性值
2.个别页面强制横竖屏
新建一个NavigationController类
实现下面三个方法
-(BOOL)shouldAutorotate
{//是否支持自动旋转
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{//支持的旋转方向
return [self.viewControllers.lastObject
supportedInterfaceOrientations];
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{//进入界面后的默认方向
return [self.viewControllers.lastObject
preferredInterfaceOrientationForPresentation];
}
如果push出的ViewController需要改变屏幕方向横屏或者竖屏
在当前的ViewController中重写这三个方法,但是如果NavigationController中实现了shouldAutorotate这个方法,则在ViewController中不再执行重写的shouldAutorotate方法。
-(BOOL)shouldAutorotate
{//是否支持自动旋转
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{//支持的旋转方向
return (枚举值);
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{//进入界面后的默认方向
return (枚举值);
}
1)targets->General->Deployment Info->Device Orientation 直接勾选想要的设备定位全局属性
2)Supporting Files->Info.plist->Supported interface orientations 增删属性值
2.个别页面强制横竖屏
新建一个NavigationController类
实现下面三个方法
-(BOOL)shouldAutorotate
{//是否支持自动旋转
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{//支持的旋转方向
return [self.viewControllers.lastObject
supportedInterfaceOrientations];
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{//进入界面后的默认方向
return [self.viewControllers.lastObject
preferredInterfaceOrientationForPresentation];
}
如果push出的ViewController需要改变屏幕方向横屏或者竖屏
在当前的ViewController中重写这三个方法,但是如果NavigationController中实现了shouldAutorotate这个方法,则在ViewController中不再执行重写的shouldAutorotate方法。
-(BOOL)shouldAutorotate
{//是否支持自动旋转
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{//支持的旋转方向
return (枚举值);
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{//进入界面后的默认方向
return (枚举值);
}
相关文章推荐
- Replace-iOS
- iOS键盘问题
- iOS 延迟执行的方式
- iOS 静态代码扫描(facebook 出品 infer)
- iOS-常见正则表达
- IOS开发基础知识--碎片16
- Xamarin iOS教程之视图显示图像
- iOS学习笔记42—利用dispatch_once创建单例
- 从零起步——10步成为专业iOS开发者
- iOS8使用CLLocationManager定位时,代理方法不执行的解决方法
- iOS GCDObjc库的使用
- iOS LLDB调试器
- IOs 推送
- IOS 十位数0补齐
- iOS数据持久化技术
- iOS音频技术
- 10步成为专业iOS开发者——从零起步
- iOS开发--查看.a文件支持的平台
- iOS开发--CocoaPods更新
- 编写高质量iOS代码