我的应用程序支持每4个方向,我有一个在LandscapeRight中的UIViewController.
我正在使用UINavigationController来推送UIViewController,我希望UIViewController仅在UIInterfaceOrientationLandscapeRight中,但是当我旋转手机时,它会切换回其他方向.
我正在使用UINavigationController来推送UIViewController,我希望UIViewController仅在UIInterfaceOrientationLandscapeRight中,但是当我旋转手机时,它会切换回其他方向.
-(BOOL)shouldAutorotate{ return NO; } -(NSUInteger)supportedInterfaceOrientations{ return UIInterfaceOrientationLandscapeRight; } -(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{ return UIInterfaceOrientationLandscapeRight; }
解决方法
只需删除那些shouldAutorotate,supportedInterfaceOrientations和preferredInterfaceOrientationForPresentation.
并将此添加到您想要仅显示横向的viewcontroller.
-(void)viewDidAppear:(BOOL)animated{ [[UIDevice currentDevice] setValue: [NSNumber numberWithInteger: UIInterfaceOrientationLandscapeLeft] forKey:@"orientation"]; }
实际上,这是来自类似问题的解决方案.
How to force view controller orientation in iOS 8?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。