1

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

4

2 回答 2

3

使用这个委托方法来控制旋转,

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

为您想要支持的方向返回“是”,为其他方向返回“否”。您可以在所有视图控制器中实现这一点。

于 2011-10-28T03:36:13.483 回答
1

您可以实现shouldAutorotateToInterfaceOrientation:each 的方法UIViewController。返回YES您希望给定视图控制器支持的方向将产生所需的结果。

请参阅UIViewController 文档

于 2011-10-28T03:38:20.513 回答