In my application UISplitViewController I have
- RootViewController - view the controller in the left pane.
- DetailViewController - view the controller in the right pane.
When one item (which is in the UITableView) in the RootViewController is used, the new view controller will be installed as follows:
[detailViewController setViewControllers:[NSArray arrayWithObjects:newViewController, nil] animated:animated];
//detailPane is my DetailViewController
Everything works very well in landscape mode. However, I cannot get the UISplitViewController to work the way I want in portrait mode, that is, the Coverage button of the RootViewController does not display properly in my DetailViewController when starting and using the application in portait mode.
When I launch the application in portrait mode, a popover button appears. But after clicking one element in a popover and a new view controller was set to detailViewController, the button disappeared. I have to turn the device to landscape, and then return to the portrait again so that the button appears again.
I set the UISplitViewController delegate to the AppDelegate application as follows:
self.splitViewController.delegate = self.detailViewController
And here is my implementation of UISplitViewControllerDelegate
- (void)splitViewController: (UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController: (UIPopoverController*)pc { NSLog(@"Will hide view controller"); barButtonItem.title = @"Menu"; [self.navigationItem setLeftBarButtonItem:barButtonItem]; self.popoverController = pc; } - (void)splitViewController: (UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem { NSLog(@"Will show view controller") NSMutableArray *items = [self.navigationItem.leftBarButtonItems mutableCopy]; [items removeAllObjects]; [self.navigationItem setLeftBarButtonItems:items animated:YES]; [items release]; self.popoverController = nil; }
Any hints or help is greatly appreciated. Thanks.
Azu
source share