PDA

View Full Version : force app to go back to portrait mode from landscape mode programmatically




ssacong
Aug 28, 2008, 07:11 PM
Hi. I have a question regarding the view orientation. As title asks, is there anyway to make app to go back to portrait mode from landscape mode by coding? Here is my situation. I am in landscape view seeing stuff, and when I touch something I would like to show new view in a portrait view, not in landscape. like in Youtube app or movie player. after you done watching the video, the view just goes back to the portrait view.

it seem like when i load up the new view it just slides in landscape mode.
is there anyway to fix this? Appreciate any suggestions



fenrus110
Nov 10, 2008, 05:41 PM
bumping this old thread, I would like to know too.

I have a couple Table Views in portrait, then when I go into the detail view, I want to be in Landscape. And when I leave Detail, I want to be in portrait for my Table Views.

and my Landscape detail isn't a graphic, it has like UILabels and UITextViews. I can't just make a landscape graphic and put it on.

fenrus110
Nov 17, 2008, 02:42 PM
I think the YouTube and MoviePlayer go in Landscape because videos MUST play in landscape mode.

[[UIDevice currentDevice] setOrientation:(UIDeviceOrientation)]

You can call this and it works, but XCode gives a warning. I have no idea if it will pass Apple's review or if the function will even exist in later versions of the SDK.

[[UIApplication sharedApplication]setStatusBarOrientation(UIInterfaceOrientation)]

I also tried this, but it only moves the status bar, it doesn't transform the view to the specified orientation.