My situation is very similar to this question . I have an app that is universal where iPhone is in portrait orientation and the iPad is in Landscape and I switch between all of my main screens using the appDelegate.window.rootViewController = newScreen; The iPhone app works perfectly. The iPad app will sometime throw the screen up in portrait orientation instead of landscape. Here is some sample transition code:
AppDelegate* appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
ViewController* v = nil;
if (IS_IPAD()) {
v = [[ViewController alloc] initWithNibName:@"ViewController-iPad" bundle:nil];
}else{
v = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
}
[appDelegate.window setRootViewController:(UIViewController*)v];
I also tried this from this other question :
AppDelegate* appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
ViewController* v = nil;
if (IS_IPAD()) {
v = [[ViewController alloc] initWithNibName:@"ViewController-iPad" bundle:nil];
}else{
v = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
}
[UIView
transitionWithView:appDelegate.window
duration:0.5
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^(void) {
BOOL oldState = [UIView areAnimationsEnabled];
[UIView setAnimationsEnabled:NO];
[appDelegate.window setRootViewController:(UIViewController*)v];
[UIView setAnimationsEnabled:oldState];
}
completion:nil];
But nothing has fixed it.
Also tried using [appDelegate.window makeKeyAndVisable] and [appDelegate.window makeKeyWindow] in the hopes that this would "shock" it into doing the correct orientation.