0

Here's my set-up:

Nav Controller: ViewcontrollerA -> ViewControllerB

ViewcontrollerB displays a imagePickerController, setting itself as Delegate

If the user hits CANCEL from the UIImagePicker, I was to dismiss ViewControllerB completely, popping the user back to ViewControllerA.

In:

-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker

I have called:

[self dismissViewControllerAnimated:YES completion:nil];

and

[[self parentViewController]  dismissViewControllerAnimated:YES completion:nil];

and

[[[self parentViewController] parentViewController]  dismissViewControllerAnimated:YES completion:nil];

No luck, ViewControllerB still hangs around.

How to I completely dismiss B programmatically from itself?

4

2 回答 2

2

ViewControllerA 是呈现 ViewControllerB 还是 ViewControllerB 是通过您的导航控制器推送的?听起来像是被推了。在这种情况下,我会尝试

[[self navigationController] popViewControllerAnimated:YES];

为清楚起见进行编辑:您确实希望以现有方式关闭图像选择器。你想用popViewControllerAnimatedViewControllerB 摆脱掉。

于 2013-10-11T17:54:06.753 回答
0

呈现视图控制器负责关闭它呈现的视图控制器。如果您在呈现的视图控制器本身上调用此方法,它会自动将消息转发到呈现的视图控制器。

[self.presentingViewController  dismissViewControllerAnimated:YES completion:nil];
于 2013-10-11T17:56:00.890 回答