从 ParentViewController 中关闭 ChildView [英] Dismiss ChildView From ParentViewController

查看:23
本文介绍了从 ParentViewController 中关闭 ChildView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个父视图,可以像这样打开子视图:

I have a parent view that opens a child view like so:

ChildViewController *child = [[ChildViewController alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:child animated:YES];

哪个工作得很好.我需要从父视图中关闭子视图,但是当我这样做时,什么也没有发生.是不是因为当我打开子视图时父视图停止了它的所有进程?或者是我的代码: [child deniedModalViewControllerAnimated:YES]; ?谢谢

Which works perfectly fine. I need to dismiss the child view from the parent view but when I do that, nothing happens. Is it because the parent view stops all of its processes when I open the child view? Or is it my code: [child dismissModalViewControllerAnimated:YES]; ? Thanks

推荐答案

dismissModalViewControllerAnimated: 必须在调用 presentModalViewController:animated: 的同一对象上调用.

dismissModalViewControllerAnimated: has to be called on the same object that presentModalViewController:animated: was called on.

在你的例子中,它需要是 [self deniedModalViewControllerAnimated:YES];

In your example, it would need to be [self dismissModalViewControllerAnimated:YES];

如果您从以模态方式显示的控制器内部解除,就像@James Bedford 描述的那样[[self parentViewController]dismissModalViewControllerAnimated:YES];

If you were dismissing from inside the controller being displayed modally, it would be as @James Bedford described [[self parentViewController] dismissModalViewControllerAnimated:YES];

这篇关于从 ParentViewController 中关闭 ChildView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆