Help with managing Autorotate views

Discussion in 'iOS Programming' started by code.warrior, Feb 19, 2009.

  1. macrumors newbie

    Feb 6, 2009

    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.
  2. thread starter macrumors newbie

    Feb 6, 2009
    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:
    -(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.

  3. macrumors 6502a

    Oct 24, 2008
    Add some logic to the shouldAutorotateToInterfaceOrientation: method in your UIViewController.

Share This Page