5

我正在尝试使用此代码强制视图定向。

-(BOOL)shouldAutorotate
{
    return YES;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeLeft;
}

发生的情况是模拟器中的视图以横向加载,当我将其转为纵向时,应用程序崩溃并出现此错误'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'。我想要发生的是,当你把它变成纵向时,它仍然是横向的并且不会崩溃。 支持的方向在 info.plist

4

2 回答 2

6

如果您尝试在 shouldAutorotate 中返回 NO?

于 2013-09-05T17:35:17.030 回答
1

你有没有尝试过

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape | UIInterfaceOrientationMaskPortrait;
}
于 2013-09-05T17:42:37.450 回答