简体   繁体   English

ipad模拟器旋转

[英]ipad simulator rotating

I am testing an application on iPad Simulator and I need it to start my app in the position the simulator is but every time I run the app, the simulator rotates to portrait. 我在iPad模拟器上测试一个应用程序,我需要它在模拟器的位置启动我的应用程序,但每次运行应用程序时,模拟器都会旋转为纵向。

Is there a way to stop this behavior? 有没有办法阻止这种行为?

thanks. 谢谢。

= = = = = = = =

last time edit: I discovered now that if I return NO on shouldAutorotateToInterfaceOrientation, the problem stops. 上次编辑:我现在发现如果我在shouldAutorotateToInterfaceOrientation上返回NO,问题就会停止。 But this is insane because shouldAutorotateToInterfaceOrientation should rotate the interface to match the iPad position, not the contrary. 但这是疯了因为shouldAutorotateToInterfaceOrientation应该旋转界面以匹配iPad的位置,而不是相反。

I had this problem when running the GHUnit test app in the simulator. 在模拟器中运行GHUnit测试应用程序时出现此问题。 I fixed it by adding this to the info.plist file: 我通过将其添加到info.plist文件来修复它:

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

If you edit this using Xcode's plist editor, make sure you have the "Show Raw Keys/Values" option turned on. 如果使用Xcode的plist编辑器进行编辑,请确保已打开“显示原始键/值”选项。

The iPad supports multiple launch images (as opposed to the iPhones singular default.png) so that an application can be launched in all rotations. iPad支持多个启动图像(与iPhones singular default.png相对),因此可以在所有轮换中启动应用程序。 Specifics here 细节在这里

I'm guessing that you are missing the new ones (default-landscape.png etc) so that when the application loads it can only find the portrait loading screen and therefor triggers a rotation (and the simulator responds by rotating to portrait). 我猜你错过了新的(default-landscape.png等),所以当应用程序加载它时,它只能找到纵向加载屏幕,因此触发旋转(模拟器通过旋转到肖像来响应)。 When you have shouldAutorotateToInterfaceOrientation return NO , it still can't find a landscape image but doesn't allow the rotation to take affect? 如果你有shouldAutorotateToInterfaceOrientation返回NO ,它仍然无法找到风景图像,但不允许旋转生效?

I think I've got it! 我想我已经拥有了!

If you close your simulator (like Cmd + Q ), then it starts always in portrait mode. 如果您关闭模拟器 (如Cmd + Q ),它将始终以纵向模式启动。

But if you close your app by pressing the home button on the simulator, then it remembers the last orientation at the next start of your app. 但是,如果您通过按模拟器上的主页按钮关闭应用程序 ,则会记住下次启动应用程序时的最后一个方向。

Once put in Landscape the sim stays in Landscape as long as you don't quit the simulator. 一旦放入横向,只要您不退出模拟器,SIM就会保留在横向中。 You can rerun your app and it will start in Landscape (well, except internally it is initially in portrait ). 您可以重新运行您的应用程序,它将从横向开始(好吧,除了内部它最初是纵向 )。

haven't tried it before... but maybe if you change the .plist file by adding 之前没有尝试过......但是如果你通过添加更改.plist文件也许

<key>UIInterfaceOrientation</key> <string>UIInterfaceOrientationPortrait</string>

I know it works on the iphone. 我知道它适用于iPhone。

Just to comfirm, I agree with everything you say above Mike but you appear to maybe coming at it from the wrong angle. 只是为了确认,我同意你在Mike上面所说的一切,但你似乎可能从错误的角度来看待它。

One of the key points of the iPad (according to apple) is apps should be fully functionable in any orientation. iPad(根据苹果公司)的关键点之一是应用程序应该可以在任何方向上完全运行。 If you read the apple speil on making the most of the additional iPad UI over the iPhone/iPod Touch, it goes into great details there. 如果你通过iPhone / iPod Touch充分利用额外的iPad用户界面阅读苹果专辑,那么它就会详细介绍。

If you use "cmd" + the left/right arrows you should be able to orientate the simulator. 如果您使用“cmd”+左/右箭头,您应该能够定向模拟器。 This will allow you to simulate exactly what a user would experience if they start your app in the wrong orientation from what you have coded. 这样,您就可以准确地模拟用户从您编码的错误方向启动应用时的体验。

I would recommend you reverse the code amendment you made(shouldAutorotateToInterfaceOrientation - NO) and code your app to display in any orientation. 我建议您撤消您所做的代码修改(shouldAutorotateToInterfaceOrientation - NO)并编写您的应用程序以便以任何方向显示。 If you must code in just one then I suspect a user will be forced to rotate the device to rectify the issue. 如果您必须只编写一个代码,那么我怀疑用户将被迫旋转设备以纠正问题。

I know you are keen to test your landscape app but I am unaware of any way the iPad Simulator can be forced to start in Landscape without you work around you mention above, which like you have already advised defeats the point. 我知道你很想测试你的风景应用程序,但我不知道任何方式iPad模拟器可以被迫在Landscape中开始,而不需要你在上面提到的工作,就像你已经建议失败的那一点。 I suspect your stuck with "cmd" + "left/right" arrows. 我怀疑你坚持使用“cmd”+“左/右”箭头。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM