I have a UISplitViewController with a UIViewController as master and a UINavigationController as my details controller (which contains an actual DetailsController as it's rootController).
In iOS5, at app startup (holding the device in landscape view), I add the splitViewController's view to my window but then I present a loginController on top of the splitViewController like this:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
KRMasterViewController *masterViewController = [[[KRMasterViewController alloc] initWithNibName:@"KRMasterViewController" bundle:nil] autorelease];
UINavigationController *masterNavigationController = [[[UINavigationController alloc] initWithRootViewController:masterViewController] autorelease];
KRDetailViewController *detailViewController = [[[KRDetailViewController alloc] initWithNibName:@"KRDetailViewController" bundle:nil] autorelease];
UINavigationController *detailNavigationController = [[[UINavigationController alloc] initWithRootViewController:detailViewController] autorelease];
self.splitViewController = [[[UISplitViewController alloc] init] autorelease];
self.splitViewController.delegate = detailViewController;
self.splitViewController.viewControllers = [NSArray arrayWithObjects:masterNavigationController, detailNavigationController, nil];
[self.window addSubview:self.splitViewController.view];
LoginController *controller=[[LoginController alloc]
initWithNibName:@"LoginController" bundle:nil];
[self.splitViewController presentModalViewController:controller animated:false];
[self.window makeKeyAndVisible];
return YES;
}
As you can see the detailsController is my splitViewController's delegate. The problem is in iOS4, before the loginController gets displayed, the delegate method:
- (void)splitViewController:(UISplitViewController *)splitController willHideViewController:(UIViewController *)viewController withBarButtonItem:(UIBarButtonItem *)barButtonItem
forPopoverController:(UIPopoverController *)popoverController
is called then when I dismiss the loginController the delegate method:
- (void)splitViewController:(UISplitViewController *)splitController willShowViewController:(UIViewController *)viewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
gets called. I guess iOS realizes really late that I'm in landscape but figures out before I got to the detailController so everything was cool. In iOS 5, the second method does not get called by the time I get to the splitViewController. This means I'm left with the barButtonItem visible in landscape view. Funny enough, if I rotate to portrait then back to landscape, the methods gets called properly from then on. Anyone ever experienced this before? Any solutions?