【问题标题】:Is there a way to be notified when a view controller load a new view controller modally?当视图控制器以模态方式加载新的视图控制器时,有没有办法得到通知?
【发布时间】:2012-07-18 06:25:51
【问题描述】:

我需要收到有关模态视图控制器演示的通知,我知道我可以使用 NSNotificationCenter 发布和观察我的自定义通知,但我想知道此类通知是否已经存在。
谢谢,
安德烈

【问题讨论】:

    标签: ios uiviewcontroller notifications modal-dialog delegation


    【解决方案1】:

    我找到了解决方案。我刚刚创建了一个抽象类,它覆盖了呈现模式视图的方法,如下所示:

    - (void) presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated{
        [[NSNotificationCenter defaultCenter] postNotificationName:PresentingModal object:self];
        [super presentModalViewController:modalViewController animated: animated];
    }
    

    当然,我所有的视图控制器都继承自它。
    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多