如何让iPhone应用程序以横向模式启动?
我的应用程序已固定为横向模式,但在viewDidLoad()甚至ViewWillAspect()期间,仍会返回以下纵向尺寸:如何让iPhone应用程序以横向模式启动?,iphone,ios,landscape,uiinterfaceorientation,portrait,Iphone,Ios,Landscape,Uiinterfaceorientation,Portrait,我的应用程序已固定为横向模式,但在viewDidLoad()甚至ViewWillAspect()期间,仍会返回以下纵向尺寸: self.view.bounds.size.width = 320.00 self.view.bounds.size.height = 480.00 直到ViewDidDisplay()才产生实际的横向尺寸 self.view.bounds.size.width = 480.00 self.view.bounds.size.height = 320.00 我觉得这很奇
self.view.bounds.size.width = 320.00
self.view.bounds.size.height = 480.00
直到ViewDidDisplay()才产生实际的横向尺寸
self.view.bounds.size.width = 480.00
self.view.bounds.size.height = 320.00
我觉得这很奇怪。
为什么会这样!?如何修复此问题?在应用程序的info.plist文件中,指定密钥:
UISupportedInterfaceOrientations
具有左右横向的值:
编辑:
原始plist代码应如下所示:
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
并返回一个横向(左或右)值
以下是一篇关于这个主题的Apple docs文章:
最后,这里是关于这个主题的其他一些SO帖子:
而且已经有那套了。UIInterfaceOrientationandscape左是的,我明白了。我是说这没什么区别。你的代码能正常工作吗?@SebastianDwornik请看第二次编辑。希望这就是现在的全部情况。我认为plist文件中的“初始接口方向”(aka.UIInterfaceOrientation)键终于完成了。谢谢。您是否在根UIViewController的-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)to interfaceOrientation方法中返回YES?我使用:return(interfaceOrientation==UIInterfaceOrientationAndscapeLeft);。我能找到的每种配置都设置为横向。仍然没有变化。我怀疑这是iOS中的一个“功能”缺陷。我只是回去看了苹果的文档。VIEWWILLEXPENCE:在配置任何动画以显示视图之前调用。由于旋转是(可以)设置动画的,这可能就是您看到未旋转大小的原因。所以我怀疑你是对的——这是一个“特征”
<key>UIInterfaceOrientation</key>
<string>UIInterfaceOrientationLandscapeRight</string>
shouldAutorotateToInterfaceOrientation