在视图中锁定纵向方向?IOS 7

n00*_*Dev 10 orientation ios

因此,我想将主页的方向锁定为纵向,仅限主页.

我正在使用标签栏控制器,因此初始视图是标签控制器,但首先出现的视图控制器是第一个标签,例如主页.

我想这样做,以便当用户旋转设备时,它不会旋转到此页面上的横向.但是所有其他页面都可以旋转.

我一直在搜索,似乎没有任何特定的iOS 7,并且特定于iOS 7的那个不起作用...

请帮帮忙,谢谢!

下面的图片描述了这个页面我想要发生的事情.

在此输入图像描述

vzm*_*vzm 7

在您的实现中实现以下内容

- (NSUInteger) supportedInterfaceOrientations {

    return UIInterfaceOrientationMaskPortrait;

}
Run Code Online (Sandbox Code Playgroud)

这应该会给你你想要的结果!


yen*_*yen 6

使用此代码

@implementation UINavigationController (Rotation_IOS6)

-(BOOL)shouldAutorotate
{

    return UIInterfaceOrientationMaskPortrait;

}

-(NSUInteger)supportedInterfaceOrientations
{

  return UIInterfaceOrientationMaskPortrait;

}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{

 return UIInterfaceOrientationPortrait;

}

@end
Run Code Online (Sandbox Code Playgroud)

  • `shouldAutorotate`应该返回'YES`. (4认同)