方向错误:'支持的方向与应用程序没有共同的方向,并且应该返回YES'

时间:2013-09-05 17:27:11

标签: iphone ios objective-c

我正在尝试使用此代码强制对视图进行定位。

-(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'。我想要发生的是,当你把它变成肖像时,它仍然保持在风景中并且不会崩溃。 The supported orientations are in the info.plist

2 个答案:

答案 0 :(得分:6)

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

答案 1 :(得分:1)

你试过吗

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape | UIInterfaceOrientationMaskPortrait;
}