SplitViewController delegate methods not responding

540 Views Asked by At

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?

2

There are 2 best solutions below

2
Mousa On BEST ANSWER

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

0
visakh7 On

Please make sure that your DetailViewController class implements the UISplitViewControllerDelegate protocol.