0

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?

Kjuly
  • 34,476
  • 22
  • 104
  • 118
addy
  • 29
  • 3

2 Answers2

1

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

visakh7
  • 26,380
  • 8
  • 55
  • 69
1

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

Mousa
  • 2,926
  • 1
  • 27
  • 35
  • what if I need that?....only at one page I need to show master/detail functionality...also you could be right...because everywhere I have seen adding splitviewcontroller at the main window – addy Dec 14 '11 at 08:15
  • 1
    Actually I needed it once and I had to make it by hand, it's not that hard just make three view controllers and make one of them contains the other two ones and set one of the subviews with, let's say 320 px width, and the other has the rest of the screen and your okay. and as for the rotation you could copy the functionality of the splitViewController and work with it. – Mousa Dec 14 '11 at 08:32