我知道我必须添加这个

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

为了使该特定的屏幕锁定在景观模式下,我是否必须为每个视图控制器执行此操作?有没有办法仅适用于所有视图控制器的主锁?

有帮助吗?

解决方案

您可以创建自己的子类 UIViewController, ,实施 -shouldAutorotateToInterfaceOrientation:.

然后,任何子类都将继承行为。

其他提示

由于您提到这是一款游戏,因此我同意将其真正应用于整个应用程序是个好主意。

如果您在项目导航器中单击项目,请选择目标,然后在“摘要”选项卡中列出了所有四个方向,您只需启用所需的方向。

对于非游戏应用程序,我不会建议这样做,因为某个地方可能需要另一个方向。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top