Loading xib depending on orientation of device whilelaunching the appliction

Discussion in 'iOS Programming' started by sagarshivam, Mar 27, 2012.

  1. sagarshivam, Mar 27, 2012
    Last edited by a moderator: Mar 27, 2012

    sagarshivam macrumors member

    May 24, 2011
    Dear All

    I have created login screen using IB. And in add-info.plist , in type: "main nib base file name", I have written name of the xib which I created using IB.

    Now in application delegate's didFinishLaunchingWithOptions method, I am simply writing
    [window makeKeyAndVisible];
    return YES
    This way, the login view (login xib)is loaded as soon as I start the application.But my problem is that this is always launched in portrait mode and there is no rotation when simulator/iPad is rotated.

    My query is that If I make two xib: one for portrait mode and other for landscape mode, how is it possible to load the one depending on the device orientation.

    Also, when I open the xib in IB, in attribute inspector, orientation of xib is always seen in default portrait (in orientation field) and I am unable to change it as it is disabled.

    Any idea is appreciated.
  2. jnoxx macrumors 65816


    Dec 29, 2010
    Aartselaar // Antwerp // Belgium
    Err, if you use the standard code, it should rotate by itself.

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
        // Return YES for supported orientations
    	return UIInterfaceOrientationIsLandscape(interfaceOrientation);
    But i'm not 100% sure how to tackle what you want, i know there is a delegate method like, "willrotate" or something, where you can load the stuff you want depending on orientation, but i would not do that. Just create your own methods, and place the stuff where you need it when the rotate will hapen

Share This Page