我在视图控制器上添加了拆分视图控制器,如下所示:
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];
但是,在DetailViewController中定义的这个方法永远不会被调用:
- (void)splitViewController: (UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController: (UIPopoverController*)pc
如果我在splitviewcontroller
中设置window
,则会调用此方法!
任何建议?
答案 0 :(得分:1)
请确保您的DetailViewController类实现UISplitViewControllerDelegate
协议。
答案 1 :(得分:1)
我知道splitViewController不能是任何其他视图的子视图,因此splitViewController必须始终是mainViewController。