横向启动应用程序会导致启动时旋转
我已经实现了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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,我想我明白了。对于从 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.
我在我的应用程序中做了类似的事情:
简单地:在开始时检测方向,然后将 StatusBarOrientation 设置为该值。如果您在加载视图之前执行此操作(或者至少在应用程序结构中尽可能早地执行此操作),则状态栏应从右侧开始出现(因此无需旋转)。
如果您还想支持纵向,只需为它们再添加 2 个其他叉子即可...
I have done something like this in my Apps:
Simply: detect Orientation at start and then set the StatusBarOrientation to that value. If you do this before you're loading your view (or at least, so earlier like possible within your App Structure), the statusbar should appear from beginning on the right side (so theres no rotation necessary).
If you want to Support also portrait orientation, simply add 2 more else forks for them...