ios - 如何关闭ModalViewControllerAnimated : YES

标签 ios uinavigationcontroller modalviewcontroller

在我决定询问之前,我阅读了很多有关此问题的文档。 所以我的应用程序中有 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/

相关文章:

ios - 如何调整 slider (从 0 到 70)

ios - CoreBluetooth - centralManagers 方法 didDiscoverPeripheral 在 sleep 模式下变得最不频繁到没有

ios - 在应用程序 iOS 中保存图像和视频

ios - 导航栏不出现

ios - 通过应用程序的 Storyboard 保持导航 Controller

ios - 在 Realm 数据库中保存数组值

ios7 - 带有纵向和横向图像的 UIBarButtonItem 可能会显示横向的纵向图像

iphone - iOS 7 中导航 Controller 及其 Root View Controller 的奇怪行为

iphone - 两个模态视图 Controller 之间的动画转换

ios - 通过 uinavigationcontroller 将变量从父 View 传递到 subview