简体   繁体   中英

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.

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. But this is insane because shouldAutorotateToInterfaceOrientation should rotate the interface to match the iPad position, not the contrary.

I had this problem when running the GHUnit test app in the simulator. I fixed it by adding this to the info.plist file:

<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.

The iPad supports multiple launch images (as opposed to the iPhones singular default.png) so that an application can be launched in all rotations. 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). When you have shouldAutorotateToInterfaceOrientation return NO , it still can't find a landscape image but doesn't allow the rotation to take affect?

I think I've got it!

If you close your simulator (like Cmd + Q ), then it starts always in portrait mode.

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. 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

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

I know it works on the iphone.

Just to comfirm, I agree with everything you say above Mike but you appear to maybe coming at it from the wrong angle.

One of the key points of the iPad (according to apple) is apps should be fully functionable in any orientation. 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.

If you use "cmd" + the left/right arrows you should be able to orientate the simulator. 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. 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. I suspect your stuck with "cmd" + "left/right" arrows.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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