Force iPad app to launch in portrait when landscape is supported

半城伤御伤魂 提交于 2019-12-24 01:17:41

问题


My iPad app contains a single view somewhere in the app that supports landscape mode.

For the shouldAutorotateToInterfaceOrientation in that view to be called I had to declare in the info.plist that landscape is supported.

Problem:

The UITabController which is shown when the app is launched doesn't support landscape mode and I made sure to specify it in all the tabbar's view controller. Yet, when the app is launched while the device is in landscape mode, the tabcontroller is shown in landscape and all the tabs looks distorted.

Setting the info.plist to support only portrait mode forces the app to launch correctly, but then the shouldAutorotateToInterfaceOrientation is ignored on the rotatable viewcontroller.

Another option I tried upon launch is:

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];

That actually forced the app to show in portrait, but also made the app ignore further device rotation on the rotatable viewcontroller.

Update: This is iOS6 issue only and cannot be spotted on the simulator


回答1:


Check this iOS 6 rotations: supportedInterfaceOrientations doesn´t work?

You need to subclass your TabBarController and override its shouldAutoRotateToInterfaceOrientation to control how this ViewController orients itself.



来源:https://stackoverflow.com/questions/12750542/force-ipad-app-to-launch-in-portrait-when-landscape-is-supported

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!