iPad UIInterfaceOrientation 启动图像后

发布于 2024-12-19 00:01:54 字数 676 浏览 2 评论 0原文

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

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

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

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

My application should support only landescape mode, so I configure the info.plist keys to get it in the right way.
My root viewcontroller is a custom UINavigationController that I add to the main window and which implement

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

The problem is that, after applicationDidFinishLaunching, interfaceOrientation is always UIInterfaceOrientationLandscapeRight even when the application was launched in UIInterfaceOrientationLandscapeLeft orientation.
The result is that the splash image is oriented properly, while the application is upsidedown.
Shaking the device for a while, make the controller rotate again in the correct direction.

Is it a bug? How do I solve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绝對不後悔。 2024-12-26 00:01:54

这对我来说非常有用

  • (BOOL)shouldAutorotateToInterfaceOrientation(UIInterfaceOrientation)interfaceOrientation
    {

    if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) {

    返回是;

    }其他{

    返回NO;

    }

    }

祝你好运

This works great for me

  • (BOOL)shouldAutorotateToInterfaceOrientation(UIInterfaceOrientation)interfaceOrientation
    {

    if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) {

    return YES;

    }else{

    return NO;

    }

    }

Good luck

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文