Search code examples
uitabbarcontrollerstoryboarduisplitviewcontroller

"- (void)splitViewController willHideViewController withBarButtonItem forPopoverController" not called


I have an application that has following schema:

Login -> Tab Bar ->

  1. UINavigationController -> Tab1ViewController
  2. UISplitViewController -> UINavigationController -> MasterViewController/DetailViewController
  3. UINavigationController -> Tab3ViewController

Then I implement in my DetailViewController

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

but it never get called.

I also have put the splitview delegate in my detail:

@interface DetailViewController : UITableViewController
<UISplitViewControllerDelegate>

Is there anything I'm missing?


Solution

  • You're missing multiple things.

    One, in order to quickly solve your problem, write:

    splitViewController.delegate = self;
    

    Two, note that it does not matter whether or not you're conforming to the <UISplitViewControllerDelegate> protocol. It's just a hint for the compiler - it does not make the view controller magically know which object is supposed to be its delegate...

    Three, as a sidenote: this has absolutely nothing to do with Xcode.