Search code examples
iphoneobjective-ciosuisplitviewcontrolleruisplitviewdelegate

SplitViewController delegate methods not responding


I have added the split view controller on a view controller as this:

rootViewController = [[RootViewController alloc] initWithStyle:UITableViewStylePlain];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];

detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
rootViewController.detailViewController = detailViewController;

splitViewController = [[UISplitViewController alloc] init];
splitViewController.viewControllers = [NSArray arrayWithObjects:navigationController, detailViewController, nil];
splitViewController.delegate = detailViewController;

[self.view addSubview:splitViewController.view];

But this method defined in DetailViewController never gets called:

- (void)splitViewController: (UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController: (UIPopoverController*)pc 

If I set the splitviewcontroller in windows, then this method gets called! Any Advise?


Solution

  • As I know the splitViewController couldn't be a subView of any other view, so the splitViewController must always be the mainViewController.