Please consider subscribing to Mobile Developer Tips RSS feed or following us on Twitter
|
|
|
I bumped into a rather odd UI issue early last week – I was working on an application which runs entirely in landscape mode. However, when I displayed an alert view, it came up as follows:

Setting Landscape Mode
In my application, I had the following interface orientation setting inside the info.plist file:

Also, I rotated the main view controller as follows to set the orientation as needed:
[self.view setCenter:CGPointMake(160.0f, 240.0f)];
[self.view setTransform:CGAffineTransformMakeRotation(3.141592f / 2.0f)];
self.view.bounds = CGRectMake(0, 0, 480, 320);
Even with the above, the device does not properly rotate the alert.
Show Alerts in Landscape Mode
To fix this, all you need to do is add the following line of code – I placed this in the applicationDidFinishLaunching method:
// Required so UIAlertView shows in the correct orientation in landscape mode
[application setStatusBarOrientation:
UIInterfaceOrientationLandscapeRight animated:NO];

Much better.
Related posts:
- Default.png and Landscape Mode
- Changing Views to Landscape Mode
- Silent Mode Switch and Playing Sounds
Comments
3 Responses to “UIAlertView and Landscape Mode”
Leave Comment
Great.
I wrote the same article in french : http://blog.netinfluence.ch/2009/05/26/uialertview-en-mode-paysage/
not with transformation, a better way I think.
^^
[Reply]
Hi. How do I make the image itself transform size? when I rotate phone image rotates but stay same size. Thanks!
Rob.
[Reply]
John Muchow Reply:
January 11th, 2010 at 6:27 pm
Hi Rob, you’ll have to resize (or use an alternate image) when rotating to landscape mode, the device will not do this for you.
[Reply]