I'm implementing a master detail application on iOS 7, the master view controller is a navigation controller which can navigate through two table view controllers. The detail is a simple view controller that displays an image.
I have implemented UISplitViewController
methods in the detail:
- (BOOL) splitViewController:(UISplitViewController *)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation
{
return UIInterfaceOrientationIsPortrait(orientation);
}
- (void) splitViewController:(UISplitViewController *)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)pc
{
UINavigationController* nav= (UINavigationController*)aViewController;
barButtonItem.title= nav.topViewController.title;
self.navigationItem.leftBarButtonItem= barButtonItem;
}
- (void) splitViewController:(UISplitViewController *)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
{
self.navigationItem.leftBarButtonItem= nil;
}
The problem is that splitViewController:willHideViewController:withBarButtonItem:forPopoverController:
is not called when the user dismisses the master view controller with a gesture.
This cases the problem that if the user navigates through the master's navigation controller and then dismisses the master, the tab bar button item shows the old title.
To make it clearer I'll explain what happens step by step. The master's navigation controller's root navigation controller's title is "Top Places". The pushed view controller's title is "Photos". When the app starts there's no master in portrait mode:
The the user presents the "Top Places" view controller:
Then the user navigates to the second view controller: "Photos":
Then the user dismisses the master, but the tab bar button item still keeps it's old title "Top Places":
The problem is that the split view controller delegate doesn't have a method called when the master is dismissed via a gesture.