presentModalViewController:如何与父进行交互

时间:2011-01-25 16:10:34

标签: iphone objective-c ios uinavigationcontroller

显示模态ViewController工作正常:

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:myView];
[self.navigationController presentModalViewController:navController animated:YES];
[navController release];    

在我的模态视图中,我有一个导航按钮可以切换回主菜单。通常情况下会调用[self.navigationController popToViewController:delegate.viewMainmenu animated:YES];,但在模态视图中不可能。我怎样才能与“父母”互动,称他为popToViewController

非常感谢!

2 个答案:

答案 0 :(得分:4)

在模态vc中使用属性parentViewController并调用 [self.parentViewController dismissModalViewControllerAnimated:YES];

答案 1 :(得分:0)

如果你问如何解雇模态视图控制器,你需要模态视图本身来调用:

[self dismissModalViewControllerAnimated:YES];