【发布时间】:2023-10-23 20:40:02
【问题描述】:
我有只支持纵向的 iPhone 应用程序。我想添加到仅支持横向方向的项目视图控制器?是否可以?如果是的话,我怎么能做到这一点?
我曾尝试像这样创建类别文件:
@implementation UINavigationController (Rotation_IOS7)
-(BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
如果我这样做,我会收到以下错误:
由于未捕获的异常而终止应用程序UIApplicationInvalidInterfaceOrientation,原因:Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES
【问题讨论】:
-
是的,您可以点击此链接*.com/questions/19827540/…
-
感谢您的回答日元,但我不确定是否是我的情况。首先,我的应用程序只针对 iOS 7,所以我不想使用 iOS 6 hacks。如果我以这种方式更改导航控制器代码,那么导航链中的另一个视图控制器呢?
-
将此代码放入您的控制器并使用 UIInterfaceOrientationMaskLandscape 而不是 UIInterfaceOrientationMaskPortrait。
标签: ios uiinterfaceorientation