如何将旋转限制为仅一个视图控制器?

时间:2011-10-28 03:29:39

标签: ios iphone screen-rotation

有没有办法将视图旋转限制为只有一个视图控制器? 例如,应用程序的其余部分保持纵向模式,但一个视图可以处于横向或纵向模式。

2 个答案:

答案 0 :(得分:3)

使用此委托方法控制旋转,

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight)
    {
        // Return YES for supported orientations
        return YES;
    }
    else
    {
        return NO;
    }
}

为您要支持的方向返回YES,为其他方向返回NO。您可以在所有视图控制器中实现此功能。

答案 1 :(得分:1)

您可以实施每个shouldAutorotateToInterfaceOrientation:的{​​{1}}方法。对于您希望给定视图控制器支持的方向返回UIViewController将产生所需的结果。

请参阅the UIViewController docs

相关问题