aryaxt
aryaxt

Reputation: 77596

iPad - Orientation change and views?

I am trying to have every viewController to display different layout depending on the screen orientation?

What is the best way to move items around?

Please explain

Upvotes: 0

Views: 1028

Answers (3)

Joel
Joel

Reputation: 1140

If it is feasible with your layout, I would make it in code. That way if you have any static elements that are on both layouts you can take advantage of the rotating animation.

If it is not feasible to do this, you can use two use by using a subview. Have 3 xibs. Your main one with any elements on both orientations. Have a view inside this view, and load from two other xibs portrait and landscape layouts.

Upvotes: 2

Jack Humphries
Jack Humphries

Reputation: 13267

It would be best to have two different XIB files. Here is some code:

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {

    if (toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {

        //show portrait XIB here

    } else {

        //show landscape XIB here

    }
}

Upvotes: 0

Abizern
Abizern

Reputation: 150565

  1. Yes - use willAnimateRotationToInterfaceOrientation:duration:
  2. You can use loadNibNamed:owner:options: as described here

Upvotes: 0

Related Questions