在我决定询问之前,我阅读了很多有关此问题的文档。 所以我的应用程序中有 navigationController 。当用户第一次进入我的应用程序时,我会这样做
RegViewController *opr = [[RegViewController alloc] init];
self.regController = opr;
[self.navigationController presentModalViewController:self.regController animated:NO];
[opr release];
而且效果很好。但是当我单击 RegViewController 中的“确定”按钮时,我调用此方法
-(IBAction)btn_regPressed:(id)sender
{
NSLog(@"start to dissmis modal");
[self.navigationController dismissModalViewControllerAnimated:YES];
//[self.navigationController.parentViewController dismissModalViewControllerAnimated:YES];
}
但是这段代码不想解雇ModalViewController 有人可以帮我解决这个问题吗?谢谢
最佳答案
尝试将您的调用更改为(删除navigationController):
[self presentModalViewController:self.regController animated:NO];
并在您的按钮中(删除navigationController):
[self dismissModalViewControllerAnimated:YES];
您告诉您的导航 Controller 关闭您的模式,但您的 View Controller 应该这样做。 导航 Controller 用于导航(前往和返回)目的。也许,你的 navigationController 为零。
关于ios - 如何关闭ModalViewControllerAnimated : YES,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10074662/