0

我在视图控制器上添加了拆分视图控制器,如下所示:

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 

如果我设置splitviewcontrollerin windows,那么这个方法就会被调用!有什么建议吗?

4

2 回答 2

1

请确保您的 DetailViewController 类实现了该UISplitViewControllerDelegate协议。

于 2011-12-14T07:26:22.933 回答
1

据我所知,splitViewController 不能是任何其他视图的子视图,因此 splitViewController 必须始终是 mainViewController。

于 2011-12-14T08:08:53.763 回答