views:

1219

answers:

5

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.

A: 

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

progrmr
thanks, but this is not the case for me. I am not setting the app to be in portrait and the simulator is always launched in portrait. Even if I set the App to be in landscape, nothing changes. It is still in portrait. Pretty annoying.
Digital Robot
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.
Digital Robot
Unfortunately nothing can be done. iPad simulator works fine though.
Mugunth Kumar
+1  A: 

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?

davbryn
I don't have a launch image, the app is light and appears fast. The problem is that apple reports that a bug appears when the app is launched when the device is in landscape. They say the app launches in portrait. As I live in Europe and foreigner developers apparently are ignored by Apple, I don't have a real device to test on. So, I am trying to see the bug on the simulator. Then I rotate the simulator and launch the app. Immediately the simulator is back to portrait, what is pretty annoying, specially because I am not setting any orientation.
Digital Robot
A: 

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.

thanks, but Apple is kicking everyone in the butt for setting a specific orientation. You should discover the device orientation when the app starts and set the app orientation accordingly.This is beautiful but there's just a little problem, a slight one, the orientation notifications are crappy as hell and they just detect an orientation if you rotate the device, not the orientation the device is on if no rotation occurred. Not to mention that the notifications take time to work and you have to delay your app until you have a trustable reading....
Digital Robot
... (continuing)... even using the accelerometer to discover the orientation does not works well, because it takes time to have a trustable reading too. Let's also forget the fact that the simulator has no accelerometer and rotates itself when the view rotates. A total mess.
Digital Robot
well... does the problem occur on the real thing?
A: 

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

Gary
A: 

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.

Hugh