Objective c iPhone-旋转不起作用

Objective c iPhone-旋转不起作用,objective-c,xcode,rotation,Objective C,Xcode,Rotation,我已经实施了 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } 在我所有的控制器中。我在info.plist中有4个方向,但我的应用程序不想旋转。唯一旋转的是顶部的杆。我的表视图不旋转…但我可以看到在我的表视图后面,它正在像它应该的那样旋转,但我无法访问它,因为我的原始表视图(不旋转的表视图)正好在它上面,占据了95%的屏幕 谢

我已经实施了

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
在我所有的控制器中。我在info.plist中有4个方向,但我的应用程序不想旋转。唯一旋转的是顶部的杆。我的表视图不旋转…但我可以看到在我的表视图后面,它正在像它应该的那样旋转,但我无法访问它,因为我的原始表视图(不旋转的表视图)正好在它上面,占据了95%的屏幕


谢谢你对我的支持

这可能对您有所帮助

     if(interfaceOrientation==UIInterfaceOrientationLandscapeLeft||interfaceOrientation==   UIInterfaceOrientationLandscapeRight||interfaceOrientation==UIInterfaceOrientationPortrait||interfaceOrientation ==UIInterfaceOrientationPortraitUpsideDown)
   {

           return YES;
   }

在ViewController.m类中,您可能想做的是复制并粘贴我的代码,如图所示,在viewDidDisapear方法下面,如下所示:

/*
- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
}
*/

 // Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations.
    return (interfaceOrientation == UIInterfaceOrientationPortrait || UIInterfaceOrientationLandscapeLeft || UIInterfaceOrientationLandscapeRight);
}
希望这有帮助

我有一个类似的例子,视图不会自动旋转。我没有解决办法,但我有解决办法。在视图控制器的willRotateToInterfaceOrientation中,显式旋转视图:

    switch (toInterfaceOrientation) {
        case UIInterfaceOrientationLandscapeLeft:
            self.view.transform = CGAffineTransformMakeRotation(M_PI * 0.5);
            break;
        case UIInterfaceOrientationLandscapeRight:
            self.view.transform = CGAffineTransformMakeRotation(M_PI * -0.5);
            break;
        case UIInterfaceOrientationPortrait:
            self.view.transform = CGAffineTransformMakeRotation(0);
            break;
        case UIInterfaceOrientationPortraitUpsideDown:
            self.view.transform = CGAffineTransformMakeRotation(M_PI * 1);
            break;
        default:
            break;
    }

我将此称为解决方法,因为我认为视图应该自动旋转,而无需显式的CGAffineTransformMakeRotation调用。在我的例子中,我正在为风景实例化一个不同的视图,我需要以这种方式旋转它。我还有其他项目,其中独立视图会自动旋转。我不知道为什么在这种情况下它不这样做。

您的自动调整大小掩码是如何设置的?self.menuTableView.autoresizingMask=UIViewAutoresizingFlexibleHeight;像这样的?顺便问一下,我应该把这个放在哪里。。。是否应在AutoRotateTointerFaceOrientation中?我把它放进去了,但它似乎没什么作用,所以我只是删除了它。把它放在viewDidLoad中,然后用所有自动调整大小的遮罩进行尝试。使用:
self.menuTableView.autoresizingMask=uiviewAutoresizingflexiblewhight | UIViewAutoresizingFlexibleWidth | uiviewAutoresizingflexiblewiftmargin | UIViewAutoresizingFlexibleWidth | uiviewAutoresizingflexiblebriftmargin | uiviewAutoresizingflexiblebriftmargin,检查所有视图控制器是否从
shouldAutorotateToInterfaceOrientation
返回YES,这也不起作用。我实际上可以看到我的表视图在“静态”表视图后面旋转。我不明白它为什么不动。可能是因为我使用了IB并拖放了一个tableView(即使我在.h中链接了它),他会把它放在哪里?他已经在所有方向的ShouldAutorotatePointerFaceOrientation中返回YES。这毫无意义。我不知道是什么原因导致了这种情况。但我现在有点讨厌:)