app锁定屏幕方向,某一个界面支持屏幕旋转~
2017-04-20 10:11
344 查看
AppDelegate.h 加
@property (nonatomic, assign) BOOL allowRotation;
Appdelegate.m加
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { if (self.allowRotation) { return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight; } return UIInterfaceOrientationMaskPortrait; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationPortrait; }
之后在需要支持屏幕旋转的界面的特定位置上添加代码:
打开屏幕旋转:AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; delegate.allowRotation = YES;
关闭屏幕旋转:
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; delegate.allowRotation = NO;
相关文章推荐
- 所有界面锁定屏幕方向,某一个界面支持屏幕旋转~
- iOS 的Viewcontroller只支持一个屏幕方向,弹出不同方向,旋转
- UIWebView中视频播放屏幕自动旋转,app不支持旋转但是某一个页面需要旋转等
- UIWebView中视频播放屏幕自动旋转,app不支持旋转但是某一个页面需要旋转等
- ios某一个屏幕支持旋转,其他不支持的方法
- 让android程序根据重力感应旋转屏幕(支持4个方向旋转)
- iOS扩展navgation,支持锁定旋转方向
- 根据系统是否支持自动旋转设置屏幕方向
- iOS开发中屏幕旋转至一个方向后再手动设置屏幕旋转至该方向无效问题
- ios开发屏幕旋转锁定时判断设备的方向
- 让android程序根据重力感应旋转屏幕(支持4个方向旋转)
- iPhone屏幕旋转锁定时判断设备的方向
- 一个关于android旋转屏幕界面的方法
- 一个APP在不同的项目中适配的一些笔记(支持多种屏幕)
- iOS开发中屏幕旋转至一个方向后再手动设置屏幕旋转至该方向无效问题
- 【MFC分享】一个支持浮点数的旋转按钮控件CNumSpinCtrl
- UIView设置为自动适配屏幕时,当用户旋转设备的时候,会调用layoutSubviews方法,我们只需重写 这个方法,然后判断用户屏幕的方向。在调整每个空间的位置即可。
- ipad/iphone ,adjust your layout when orientation will be changing , 旋转屏幕时调整界面布局
- Get swipe direction in Cocoa Touch:UISwipeGestureRecognizer只能同时支持一个方向
- Android开发: 通过修改数据库改变屏幕旋转方向screen rotation