How to change orientation to landscape on button event
+1
A:
I found this online:
application.statusBarOrientation = UIInterfaceOrientationLandscapeRight;
There is also an event which is triggered when you change the orientation of the phone where you specify the allowed mode (portrait or landscape).
Hope that helps.
Littlejon
2009-10-02 06:59:09
thanks, But I want to put abutton on navigation bar to change the orientation to landscape. Is tere any way to do so ?
nic
2009-10-02 07:03:33
I haven't tried it but the application.statusBarOrientation seems like it could do the trick. You will need to create an event for the nav bar button push then put this code in.
Littlejon
2009-10-02 07:04:53
http://iphonesdkdev.blogspot.com/2008/08/how-to-force-orientation-to-landscape.html
Littlejon
2009-10-02 07:06:41
Of course, you need to have declared an `application` variable and set it to `[UIApplication sharedApplication]` for the above code sample to work. If you were only using this once, you could use `[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];`.
Steve Harrison
2009-10-02 07:18:11
...or `[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeRight;` if you prefer dot-notation syntax...
Steve Harrison
2009-10-02 07:19:40