以横向模式启动应用会导致轮播

我已经实现了shouldAutorotateToInterfaceOrientation,一切正常运行时,我的应用程序中的条款或方向更改一切正常。 不过,我不喜欢我的应用程序在第一次启动时的行为。

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

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

我怎样才能确保我的应用程序加载在正确的方向,使用户在启动时看不到旋转animation。 如果用户在启动后旋转设备,只看到旋转animation,我更喜欢它。

好吧,我想我明白了。 对于任何人从iPhone tempalte创build应用程序,然后修改它为iPad,你需要在你的-info.plist文件中添加一行“支持的接口方向”,并input所有支持的方向如下。 那么它似乎按预期工作。

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

我在我的Apps中做了这样的事情:

 if ([[UIDevice currentDevice] orientation]==UIInterfaceOrientationLandscapeRight){ [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight]; }else if ([[UIDevice currentDevice] orientation]==UIInterfaceOrientationLandscapeLeft){ [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft]; } 

只需:在开始时检测方向,然后将StatusBarOrientation设置为该值。 如果您在加载视图之前(或者至less在您的应用程序结构中尽可能早些时候这样做),则状态栏应该从右侧开始出现(因此不需要轮转)。 如果你想支持肖像取向,只需添加两个更多的叉子为他们…