Targeting Iphone and 2 Nib Files

I am trying to create an application in which each view controller (.h / .m) has 2 NIB files ... one for portrait, one for landscape. Is this the "standard" way of supporting orientation, or should I manually adjust the orientation view programmatically? The problem I am facing is that when the user flips the orientation, all views are reset (so the user must re-enter the input of text fields / views).

Here is my orientation method:

- (void) changeTheViewToPortrait:(BOOL)portrait andDuration:(NSTimeInterval)duration{ [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:duration]; if(portrait) { [[NSBundle mainBundle] loadNibNamed:@"myview-portrait" owner:self options:nil]; [self setupLayout]; } else{ [[NSBundle mainBundle] loadNibNamed:@"myview-landscape" owner:self options:nil]; [self setupLayout]; } [UIView commitAnimations]; 

}

+6
ios iphone ipad nib orientation
source share
1 answer

Apple has several different suggestions for supporting multiple orientations in the View Controller Programming Guide in the "Controlling the View View Controller Interface Orientation" section. You might want to read this section to find out if any of their suggestions will better suit your needs.

As I said, I used the strategy presented above in the application, and it seems to work very well.

To solve your problem with the "reset" views, I would suggest that you keep a link to the data entered by the user when moving from the control to the control. Then, when your orientation changes, you can re-fill the controls so that the "progress" of the user is not lost.

+7
source share

All Articles