我在尝试从 iOS 6 设置新的 UIInterfaceOrientations 时遇到了麻烦。
恢复我的应用:
- 我的应用有很多 View ;
- 几乎每个 View 都应以纵向显示;
- 我的 2 个 View (使用
MPMoviePlayerViewController
播放视频的 View )应该向左、向右和纵向旋转。
我最初的想法是将应用支持的方向设置为纵向,然后更改(不知道如何)从视频播放器 View 支持的方向。
处理此问题的最佳方法是什么?
提前致谢!
最佳答案
通过将 Supported Interface Orientations 设置为我需要的所有内容(纵向、左右横向)并添加 UINavigationController
的一个 Category
解决了这个问题。
我将类别添加到任何我想保持纵向模式的 UINavigationController
并将 iOS 6 旋转视为 this post :
@implementation UINavigationController (Rotation_IOS6)
-(BOOL)shouldAutorotate
{
return NO;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationPortrait;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
@end
实现后我仍然有一些问题,因为代码是这样的:
[self.window.rootViewController presentModalViewController:controller animated:NO];
而不是这个:
[self.navigationController pushViewController:controller animated:NO];
通过上述更改,我能够将整个应用程序保持在纵向模式并让视频播放器 View 保持旋转,因为它们的方法(shouldRotate 和 supportedInterfaceOrientations)没有被覆盖。
关于iphone - iOS 6 的多个 UIInterfaceOrientations 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12610132/