Ios 仅一个视图控制器的设备方向纵向图

Ios 仅一个视图控制器的设备方向纵向图,ios,iphone,Ios,Iphone,我只想要一个视图控制器中的纵向方向。我正在这样做: -(BOOL)shouldAutorotate{ return NO; } -(NSInteger)supportedInterfaceOrientations:(UIWindow *)window{ // UIInterfaceOrientationMaskLandscape; // 24 // // UIInterfaceOrientationMaskLandscapeLeft;

我只想要一个视图控制器中的纵向方向。我正在这样做:

-(BOOL)shouldAutorotate{
    return NO;
}

-(NSInteger)supportedInterfaceOrientations:(UIWindow *)window{

    //    UIInterfaceOrientationMaskLandscape;
    //    24
    //
    //    UIInterfaceOrientationMaskLandscapeLeft;
    //    16
    //
    //    UIInterfaceOrientationMaskLandscapeRight;
    //    8
    //
    //    UIInterfaceOrientationMaskPortrait;
    //    2


    //    return UIInterfaceOrientationMaskLandscape;
    return 2;
}  
没有成功!!
我已经尝试了上建议的许多排列和组合,但仍然不起作用。

您应该在shouldAutorotate中返回YES,因为如果您的应用程序处于横向,则在其他情况下,您的视图无法旋转回纵向

您应该尝试为shouldAutoRotate返回YES,以使下面的supportedInterfaceOrientations生效,而且UIViewController上没有名为-NSIntegersupportedInterfaceOrientations:UIWindow*window的方法,请改用:

此代码必须进入您希望仅处于纵向的视图控制器中

-(BOOL)shouldAutorotate
{
    return YES;
}

-(NSInteger)supportedInterfaceOrientations
{
   return UIInterfaceOrientationMaskPortrait;
}

我给你链接了一个帖子,在这里我回答了这样一个问题。我希望这会有帮助

可能重复的