views:

38

answers:

1

I have a helloController which is a UIViewController, if I rotate the device, I want it change it to load a new nib "helloHorizontal.xib", how can I do? thank you.

A: 

You could you something like this, (I dont have xcode handy so this code might not be completely accurate)

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if((interfaceOrientation == UIInterfaceOrientationLandscapeRight) || (interfaceOrientation == UIInterfaceOrientationLandscapeLeft)){
WhatYourNewViewClassISCAlled* newView = [[WhatYourNewViewClassISCAlled alloc] initWithNibName:@"NIBNAME" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:newView animated:YES];
}
octermircty
But then the portrait-oriented view will still be on the stack, won't it? So the back button will point to the wrong thing.
Tommy Herbert
Good point, you could hide the nav bar when the views rotated or have the view already created and fade it in and fade the other view out when the rotation occurs.
octermircty