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?