0

I want to create UISplitView programmatically after pressing a button in a view. For UISplitView, I have two view controllers called as MyTableViewController and MyDetailViewController. This is what I am doing in the action of the button:

UISplitViewController* splitVC = [[UISplitViewController alloc] init];
MyTableViewController* firstVC = [[MyTableViewController alloc] init];
MyDetailViewController* secondVC = [[MyDetailViewController alloc] init];

UINavigationController *leftNavController = [[UINavigationController alloc] init];
[leftNavController pushViewController:firstVC animated:NO];

splitVC.viewControllers = [NSArray arrayWithObjects:leftNavController, secondVC, nil];

AppDelegate * appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate.window setRootViewController:splitVC];

But secondVC (the detail view) doesn't show up. It is just black. Though, the firstVC (the table view) shows up as it should be. What could be the reason?

4

1 回答 1

0

您应该看看 using [self.storyboard instantiateViewControllerWithIdentifier:@"DetailViewIdentifier"],并在情节提要中为视图控制器设置标识符。调用init视图控制器不会引用您创建的情节提要,因此您需要将视图控制器拉出情节提要。表格视图有效,因为它的布局被编程到UITableViewController类中。

于 2013-07-19T18:17:04.540 回答