如何在iPad中的DetailViewController中加载另一个视图

时间:2011-01-05 05:48:00

标签: iphone xcode ipad

如何在单击按钮时将Nib文件中的视图加载到iPad的DetailView中,并在子视图中单击另一个按钮时返回上一个视图。

2 个答案:

答案 0 :(得分:1)

答案 1 :(得分:1)

以下代码应引导您朝着正确的方向前进。

加载新的ViewController:

- (IBAction)myBtnPushed{
NSLog(@"myBtnPushed");

NewRightVC *newRightVC = [[NewRightVC alloc] initWithNibName:@"NewRightVC" bundle:[NSBundle mainBundle]];
[detailViewController.navigationController pushViewController:newRightVC animated:YES];

NewLeftVC *newLeftVC = [[NewLeftVC alloc] initWithNibName:@"NewLeftVC" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:newLeftVC animated:YES];
}

回到UISplitViewController中的RootViewController和DefaultViewController:

[detailViewController.navigationController popViewControllerAnimated:YES];

[self.navigationController popViewControllerAnimated:YES];

Example Project to examine can be downloaded here.

Example obtained from this post: https://stackoverflow.com/questions/5263128/splitviewcontroller-with-two-navigationcontroller-linking-protocols