ios – 在我看来,DidAppear,我怎么知道什么时候被小孩解开?

ios – 在我看来,DidAppear,我怎么知道什么时候被小孩解开?,第1张

概述当我的孩子执行展开时,我的控制器的viewDidAppear被调用. 在这种方法中(仅仅这种方法,我需要知道是否来自放松) 注意:孩子正在放松到第一个视图控制器,所以这是一个中间视图控制器,而不是真正的根. 如果视图控制器的曝光是由于被推送/呈现而导致的,或者由于d出/关闭/展开而导致暴露,则应该能够使用以下内容来检测每个控制器. 这可能或可能足以满足您的需求. - (void) viewDidA 当我的孩子执行展开时,我的控制器的vIEwDIDAppear被调用.

在这种方法中(仅仅这种方法,我需要知道是否来自放松)

注意:孩子正在放松到第一个视图控制器,所以这是一个中间视图控制器,而不是真正的根.

解决方法 如果视图控制器的曝光是由于被推送/呈现而导致的,或者由于d出/关闭/展开而导致暴露,则应该能够使用以下内容来检测每个控制器.

这可能或可能足以满足您的需求.

- (voID) vIEwDIDAppear:(BOol)animated{    [super vIEwDIDAppear:animated];    // Handle controller being exposed from push/present or pop/dismiss    if (self.isMovingtoparentVIEwController || self.isBeingPresented){        // Controller is being pushed on or presented.    }    else{        // Controller is being shown as result of pop/dismiss/unwind.    }}

如果你想知道vIEwDIDAppear是被调用的,因为一个放松的segue与传统的pop / dismiss被调用不同,那么你需要添加一些代码来检测是否发生了一个展开.为此,您可以执行以下 *** 作:

对于任何中间控制器,您只需要检测出来,就可以添加以下形式的属性:

/** BOol property which when TRUE indicates an unwind occured. */@property BOol unwindSeguePerformed;

然后覆盖展开方法canPerformUnwindSegueAction:fromVIEwController:withSender:方法如下:

- (BOol)canPerformUnwindSegueAction:(SEL)action                 fromVIEwController:(UIVIEwController *)fromVIEwController                         withSender:(ID)sender{  // Set the flag indicating an unwind segue was requested and then return  // that we are not interested in performing the unwind action.  self.unwindSeguePerformed = TRUE;  // We are not interested in performing it,so return NO. The system will  // then continue to look backwards through the vIEw controllers for the   // controller that will handle it.  return NO;}

现在你有一个标志来检测放松和一种在发生之前检测放松的方法.然后调整vIEwDIDAppear方法来包含这个标志.

- (voID) vIEwDIDAppear:(BOol)animated{    [super vIEwDIDAppear:animated];    // Handle controller being exposed from push/present or pop/dismiss    // or an unwind    if (self.isMovingtoparentVIEwController || self.isBeingPresented){        // Controller is being pushed on or presented.        // Initialize the unwind segue tracking flag.        self.unwindSeguePerformed = FALSE;    }    else if (self.unwindSeguePerformed){        // Controller is being shown as a result of an unwind segue    }    else{        // Controller is being shown as result of pop/dismiss.    }}

希望这符合您的要求.

有关处理展开链的文档,请参阅:https://developer.apple.com/library/ios/technotes/tn2298/_index.html

总结

以上是内存溢出为你收集整理的ios – 在我看来,DidAppear,我怎么知道什么时候被小孩解开?全部内容,希望文章能够帮你解决ios – 在我看来,DidAppear,我怎么知道什么时候被小孩解开?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1113455.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存