1.创建工程,设置Device Orientation
2.在AppDelegate中实现下面这个方法:
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
if (self.allowRotation) {
return UIInterfaceOrientationMaskLandscapeRight;
}
return UIInterfaceOrientationMaskPortrait;
}
此属性默认是NO,在需要旋转的界面将属性设置为YES.
还没有完,有人会问,那我如何去控制屏幕旋转呢?别着急请往下看
一般我们手动控制屏幕横竖屏切换肯定是需要触发事件对吧!
那如何去手动控制屏幕旋转呢?
在触发旋转事件中:
[AppDelegate sharedAppDelegate].allowRotation = YES;
self.navigationController.navigationBar.hidden = YES;
NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
这样就实现了强制旋转某个试图控制器。
如果想偷个懒,那么你出钱,我们出力.定制专属于你的APP请咨询我们:山东六牛网络科技有限公司
最后
以上就是大意钻石最近收集整理的关于iOS 强制屏幕实现旋转功能的全部内容,更多相关iOS内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复