不调用呈现视图控制器的dismissModalViewContr

不调用呈现视图控制器的dismissModalViewContr

本文介绍了模态视图控制器不调用呈现视图控制器的dismissModalViewControllerAnimated:方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的模态视图控制器中,我有一个按钮处理方法,包括

In my modal view controller I have a button handling method that includes

[self dismissModalViewControllerAnimated: YES];

在呈现视图控制器中,我重写dismissModalViewControllerAnimated:如下所示:

In the presenting view controller I override dismissModalViewControllerAnimated: as follows:

-(void) dismissModalViewControllerAnimated: (BOOL)animated
{
  NSLog(@"dismiss");
  [super dismissModalViewControllerAnimated: animated];
}

触摸按钮时,会调用按钮处理方法,但是dismissModalViewControllerAnimated :覆盖似乎没有被调用:NSLog(@dismiss);语句未被调用,方法内的断点不会被命中。

When the button is touched, the button handling method gets called, but the dismissModalViewControllerAnimated: override does not seem to get called: the NSLog(@"dismiss"); statement isn't called, and a breakpoint inside the method doesn't get hit.

我试过

[[self presentingViewController] dismissModalViewControllerAnimated: YES];

但这也不起作用。但是,模态视图控制器确实被解雇了。

but that didn't work either. However, the modal view controller does get dismissed.

知道可能出现什么问题吗?

Any idea what might be going wrong?

推荐答案

呈现模态视图控制器的代码包含在UIViewController中,而UIViewController又包含在UINavigationController中。当我打电话

The code that presented the modal view controller was contained in a UIViewController, which was in turn contained in a UINavigationController. When I called

[[self presentingViewController] dismissModalViewControllerAnimated: YES];

[self dismissModalViewControllerAnimated: YES];

解雇消息被发送到UINavigationController对象。

the dismissal message was being sent to the UINavigationController object.

这篇关于模态视图控制器不调用呈现视图控制器的dismissModalViewControllerAnimated:方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 03:33