PDA

View Full Version : Help with managing Autorotate views




code.warrior
Feb 20, 2009, 01:28 AM
Hi,

Kindly help me in this regard. In my application, I'm developing two different view controllers, one for portrait mode and one for landscape mode, when the device will be rotated.
So I want the portrait view controller to load when the device is in portrait mode and it should load landscape view controller when device is rotated to landscape mode.
I'm using 'UIWindow' to manage these view controllers.

How shall I achieve this?


Thanks for reading through.



code.warrior
Feb 20, 2009, 04:20 AM
oh, anyways, well I found out the way.
For the future purpose, if anyone( like me ) needs this, then here is the solution. Use the one of the following methods, according to the need of the application, in your application delegate:

-(void) application:willChangeStatusBarOrientation:duration:
Or
-(void) application:didChangeStatusBarOrientation:
And in those methods, set the appropriate view controller as the subview of the main application view, according to the orientation of the device.
That's all.


Thanks

jnic
Feb 20, 2009, 04:28 AM
Hi,

Kindly help me in this regard. In my application, I'm developing two different view controllers, one for portrait mode and one for landscape mode, when the device will be rotated.
So I want the portrait view controller to load when the device is in portrait mode and it should load landscape view controller when device is rotated to landscape mode.
I'm using 'UIWindow' to manage these view controllers.

How shall I achieve this?


Thanks for reading through.

Add some logic to the shouldAutorotateToInterfaceOrientation: method in your UIViewController (https://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html).