【问题标题】:How can I check if UIViewController "Did Dismiss"?如何检查 UIViewController 是否“解雇”?
【发布时间】:2010-08-03 11:48:05
【问题描述】:

我想知道,我在 A 类中有一个 UIButton presentModalViewController:aViewController...

我想检查 aViewController 何时被解除。

我该怎么做?

谢谢!

【问题讨论】:

    标签: model-view-controller uiviewcontroller presentmodalviewcontroller


    【解决方案1】:

    事实上,你不能。没有通知(Bad Work apple)。

    但是有一个解决办法:

    在调用presentModalViewController函数的viewController中使用viewDidAppear、viewWillAppear、viewWillDesappear、viewDidDesappear族

    想法:

    .h:

    BOOL hasModal;
    

    .m :

    -(void)presentModal
    {
       hasModal = YES;
       [self presentModalViewController:_viewController animated:YES];
    }
    
    
    -(void)viewDidAppear:(BOOL)animated
    {
      [super viewDidAppear:animated];
      if(hasModal)
      {
        // your code 
      }
    }
    

    祝你好运^^

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-06-30
      • 2014-01-01
      • 1970-01-01
      • 2011-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-03
      相关资源
      最近更新 更多