Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/44.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 从ParentViewController中取消ChildView_Iphone_Objective C_Uiviewcontroller - Fatal编程技术网

Iphone 从ParentViewController中取消ChildView

Iphone 从ParentViewController中取消ChildView,iphone,objective-c,uiviewcontroller,Iphone,Objective C,Uiviewcontroller,我有一个打开子视图的父视图,如下所示: ChildViewController *child = [[ChildViewController alloc] initWithNibName:nil bundle:nil]; [self presentModalViewController:child animated:YES]; 这很好用。我需要从父视图中取消子视图,但是当我这样做时,什么也不会发生。是否因为父视图在我打开子视图时停止了所有进程?还是我的代码:[child dismissModa

我有一个打开子视图的父视图,如下所示:

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

这很好用。我需要从父视图中取消子视图,但是当我这样做时,什么也不会发生。是否因为父视图在我打开子视图时停止了所有进程?还是我的代码:
[child dismissModalViewControllerAnimated:YES]?谢谢

您打电话到哪里
[儿童解职Modalviewcontrolleranimated:是]?这行代码是否曾经被访问过

您可以将目标/操作添加到您的ChildViewController类中的一个uicontrol,该类使用继承的parentViewController属性来解除自身,如下所示:


[[self-parentViewController]解除ModalViewController激活:是]

必须对当前调用ModalviewController:animated:的同一对象调用DismissModalviewController:animated:

在您的示例中,它需要是
[self dismissModalViewControllerAnimated:YES]


如果您是从正在以模式显示的控制器内部解除,则它将如@James Bedford所述
[[self parentview controller]dismissModalViewControllerAnimated:YES]

正在从父级调用代码行,但子级未关闭。我在那里放了一个NSLog,它显示在控制台中,所以我知道它是从家长那里调用的。谢谢你帮我清理。我以为你应该从孩子的角度来看待自我解构,但我想不是。