Objective c 即使我在shouldAutorotate上返回NO,视图也会被旋转

Objective c 即使我在shouldAutorotate上返回NO,视图也会被旋转,objective-c,ios,uiview,uiviewcontroller,Objective C,Ios,Uiview,Uiviewcontroller,我有一个ViewController,我有以下代码: - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return NO; } 但是,如果更改方向,视图将旋转。有人能帮我吗?以下是我如何让iPad保持横向模式的方法: - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrien

我有一个ViewController,我有以下代码:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

    return NO;

}

但是,如果更改方向,视图将旋转。有人能帮我吗?

以下是我如何让iPad保持横向模式的方法:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (interfaceOrientation==UIInterfaceOrientationLandscapeLeft || interfaceOrientation==UIInterfaceOrientationLandscapeRight)
{
    return YES;
}

else
{
    return NO;
}

}

如果它是您支持的方向,请尝试使其返回YES(是)(您至少需要1对吗?)。取决于UIViewController(或使用此方法确定旋转的代码)的实现,这可能对您的问题有帮助,也可能没有帮助,但更正确。@Matt:我也尝试过这种方法。。。不工作:(和我一样的问题,是什么解决了你的问题?我也有类似的问题。它仍然旋转:(…视图控制器位于导航控制器内,其下有更多视图控制器。您认为这可能会导致问题吗?是的,您是否将代码放入mainViewcontroller???如果不起作用,请查看如何在应用程序的plist中指定它。noope,它不在根视图控制器中。我的代码是另一个视图控制器r,我将其推入导航控制器堆栈。plist应允许所有旋转。仅在该特定视图控制器上,它应仅为横向(左/右)。