横向启动应用程序会导致启动时旋转 [英] Launching app in landscape orientation causes rotation on launch

查看:28
本文介绍了横向启动应用程序会导致启动时旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现了 shouldAutorotateToInterfaceOrientation 并且在我的应用程序运行后一切正常或方向变化.但是,我不喜欢我的应用程序首次启动时的行为.

I have implemented shouldAutorotateToInterfaceOrientation and everything works fine in terms or orientation changes in my app once it is running. However I don't like the behavior of my app when it is fist launched.

当我以纵向方向启动我的应用程序时,它会按预期打开,但是当我以横向方向启动我的应用程序时,我看到所有内容都以纵向方向加载(包括状态栏),然后我看到屏幕旋转的动画到景观.该动画很好,但我不希望它在启动时显示.

When I launch my app in portrait orientation, it opens as expected, however when I launch my app in landscape orientation, I see everything load in portrait orientation (including the status bar), then I see an animation of my screen rotating to landscape. That animation is fine, but I don't want it to be displayed at launch.

当我查看大多数其他应用时,它们似乎在启动时检测到方向,并且在启动时不显示旋转动画(仅当设备在启动时间后旋转时).

When I look at most other apps, they seem to detect the orientation as they launch and they do not show the rotation animation on launch (only if the device is rotated after launch time).

如何确保我的应用以正确的方向加载,以便用户在启动时看不到旋转动画.如果用户在启动后旋转设备时只看到旋转动画,我会更喜欢它.

How can I make sure my app loads in the proper orientation so the user does not see the rotation animation on launch. I would prefer it if the user only saw the rotation animation if he/she rotates the device after launching.

推荐答案

好吧,我想我想通了.对于从 iPhone 模板创建应用程序然后为 iPad 修改它的任何人,您需要在 -info.plist 文件中添加一行显示支持的界面方向"并输入所有支持的方向,如下所示.然后它似乎按预期工作.

Okay I think I figured it out. For anybody who created an app from an iPhone tempalte and then modified it for iPad, you need to add a line in your -info.plist file that says "Supported interface orientations" and enter all of the supported orientations as below. Then it seems to work as expected.

    <key>UISupportedInterfaceOrientations</key>
<array>
    <string>UIInterfaceOrientationPortrait</string>
    <string>UIInterfaceOrientationPortraitUpsideDown</string>
    <string>UIInterfaceOrientationLandscapeLeft</string>
    <string>UIInterfaceOrientationLandscapeRight</string>
</array>

这篇关于横向启动应用程序会导致启动时旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆