0

我的应用程序应该只支持横向模式,所以我配置 info.plist 键以正确的方式获取它。
我的根视图控制器是一个自定义 UINavigationController 我添加到主窗口并实现

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

问题是,在 applicationDidFinishLaunching 之后,interfaceOrientation即使应用程序以 UIInterfaceOrientationLandscapeLeft 方向启动,它也始终是 UIInterfaceOrientationLandscapeRight。
结果是启动图像的方向正确,而应用程序是颠倒的。
摇晃设备片刻,使控制器再次按正确方向旋转。

它是一个错误吗?我该如何解决这个问题?

4

1 回答 1

0

这对我很有用

  • (BOOL)应该自动旋转到接口方向(UIInterfaceOrientation)接口方向{

    如果(UIInterfaceOrientationIsLandscape(interfaceOrientation)){

    返回是;

    }别的{

    返回否;

    }

    }

祝你好运

于 2011-12-01T09:12:57.943 回答