2
votes

My iPad app uses the standard UISplitViewController. My problem is, if I

  • Rotate to portrait, I put a Popover button for the Master list - Fine
  • Select an item via the popover, that changes the detailview (This uses a prepareForSegue which sets self.splitViewController.delegate = newViewDetailViewController;
  • The resulting detailview is now missing a popoverbutton. If I rotate to landscape, the master list appears. If I then again rotate to portrait, a popoverbutton appears.

So - How can I ensure willHideViewController will be called on viewDidLoad, for example? I can detect what the orientation is, but I still need the barbuttonitem and popovercontroller needed in

- (void)splitViewController:(UISplitViewController *)splitController willHideViewController:(UIViewController *)viewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)popoverController

For now I am following Apples MultipleDetailView example as suggested here.

But since I am having multiple MasterControllers as well, it's a real hassle to store (a static) pointer to the popoverbutton item and setting it every time I push a level on my masterview controller.

Hopefully, someone has a good way of solving this problem :-)

1
I'm having this same issue, did you ever get it figured out?Bek
I ended using the example I linked to from Apple. It wasn't an issue with multiple mastercontrollers, since I realized that the popoverbutton gets delivered to me in the willHideViewController method. So, I have a SubstitutableDetailViewController protocol that my detail views implement.CracyD
I'm having the same problem, and I'm using the same Apple sample code that uses the SubstitutableDetailViewController protocol. It doesn't receive (void)splitViewController:(UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem when the view controller was loaded before and rotated when it was not visible.avance

1 Answers

3
votes

I ran into the same problem and finally figured out what was missing. There is a little code in the AppDelegate to performs some initialization. It is in the didFinishLaunchingWithOptions method. Here is the code that goes in there:

UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
UINavigationController *navigationController = [splitViewController.viewControllers lastObject];
splitViewController.delegate = (id)navigationController.topViewController;

They're all important to operate the split view controller, but the last line is the most line for getting the method to fire is the last one. I am building a universal application and this was missing. To ensure that it didn't affect my iPhone side I wrapped it in a UI_USER_INTERFACE_IDIOM check.