Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 定向误差:';支持的方向与应用程序没有共同的方向,shouldAutorotate返回YES';_Iphone_Ios_Objective C - Fatal编程技术网

Iphone 定向误差:';支持的方向与应用程序没有共同的方向,shouldAutorotate返回YES';

Iphone 定向误差:';支持的方向与应用程序没有共同的方向,shouldAutorotate返回YES';,iphone,ios,objective-c,Iphone,Ios,Objective C,我试图使用此代码在视图上强制定向 -(BOOL)shouldAutorotate { return YES; } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInter

我试图使用此代码在视图上强制定向

-(BOOL)shouldAutorotate
{
    return YES;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeLeft;
}
发生的情况是,在横向模拟程序中加载视图,当我将其转到纵向时,应用程序崩溃,我得到此错误
“支持的方向与应用程序没有共同的方向,并且shouldAutorotate返回YES”
。我想发生的是,当你们把它变成肖像画时,它仍然在风景中,不会崩溃。

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

您尝试过吗

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

抱歉,我误解了问题-(NSInteger)supportedInterfaceOrientations描述:“仅当视图控制器的shouldAutorotate方法返回YES时才会调用此方法。”@Nico请查看Morkrom注释,为什么返回NO?