• <i id='zQZsL'><tr id='zQZsL'><dt id='zQZsL'><q id='zQZsL'><span id='zQZsL'><b id='zQZsL'><form id='zQZsL'><ins id='zQZsL'></ins><ul id='zQZsL'></ul><sub id='zQZsL'></sub></form><legend id='zQZsL'></legend><bdo id='zQZsL'><pre id='zQZsL'><center id='zQZsL'></center></pre></bdo></b><th id='zQZsL'></th></span></q></dt></tr></i><div id='zQZsL'><tfoot id='zQZsL'></tfoot><dl id='zQZsL'><fieldset id='zQZsL'></fieldset></dl></div>

          <bdo id='zQZsL'></bdo><ul id='zQZsL'></ul>

        <small id='zQZsL'></small><noframes id='zQZsL'>

        <legend id='zQZsL'><style id='zQZsL'><dir id='zQZsL'><q id='zQZsL'></q></dir></style></legend>
      1. <tfoot id='zQZsL'></tfoot>

        检测视图控制器何时从弹出窗口出现

        时间:2023-06-12
          • <i id='ohmiV'><tr id='ohmiV'><dt id='ohmiV'><q id='ohmiV'><span id='ohmiV'><b id='ohmiV'><form id='ohmiV'><ins id='ohmiV'></ins><ul id='ohmiV'></ul><sub id='ohmiV'></sub></form><legend id='ohmiV'></legend><bdo id='ohmiV'><pre id='ohmiV'><center id='ohmiV'></center></pre></bdo></b><th id='ohmiV'></th></span></q></dt></tr></i><div id='ohmiV'><tfoot id='ohmiV'></tfoot><dl id='ohmiV'><fieldset id='ohmiV'></fieldset></dl></div>
              <bdo id='ohmiV'></bdo><ul id='ohmiV'></ul>
                <tbody id='ohmiV'></tbody>

                <legend id='ohmiV'><style id='ohmiV'><dir id='ohmiV'><q id='ohmiV'></q></dir></style></legend>
                1. <tfoot id='ohmiV'></tfoot>

                  <small id='ohmiV'></small><noframes id='ohmiV'>

                  本文介绍了检测视图控制器何时从弹出窗口出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在导航堆栈深处弹出一个视图控制器.是否可以检测视图控制器是从推送还是弹出显示?

                  I am popping a view controller deep within a navigation stack. Is it possible to detect if the view controller is being shown from a push or a pop?

                  nav stack:
                  
                  [A] -> [B] -> [C] -> [D] -> [E]
                  

                  [E] 弹出到 [B]

                  [E] pops to [B]

                  nav stack:
                  
                  [A]  -> [B] // Possible to detect if B appears from a pop?
                  

                  推荐答案

                  在视图控制器 B 中,实现 viewWillAppearviewDidAppear.在那里,使用 isMovingToParentisBeingPresented 来查看它在什么条件下出现:

                  In view controller B, implement either viewWillAppear or viewDidAppear. In there, use isMovingToParent and isBeingPresented to see under what conditions it is appearing:

                  override func viewWillAppear(_ animated: Bool) {
                      super.viewWillAppear(animated)
                  
                      if !isBeingPresented && !isMovingToParent {
                          // this view controller is becoming visible because something that was covering it has been dismissed or popped
                      }
                  }
                  

                  以下是人们可能会觉得方便的这些属性的更一般用法:

                  Below is a more general use of these properties that people may find handy:

                  override func viewWillAppear(_ animated: Bool) {
                      super.viewWillAppear(animated)
                  
                      if isMovingToParent {
                          // this view controller is becoming visible because it was just push onto a navigation controller or some other container view controller
                      } else if isBeingPresented {
                          // this view controller is becoming visible because it is being presented from another view controller
                      } else if view.window == nil {
                          // this view controller is becoming visible for the first time as the window's root view controller
                      } else {
                          // this view controller is becoming visible because something that was covering it has been dismissed or popped
                      }
                  }
                  

                  这篇关于检测视图控制器何时从弹出窗口出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:self.tabBarItem.title 不工作? 下一篇:选择选项卡时弹出到根视图

                  相关文章

                2. <small id='L8NLT'></small><noframes id='L8NLT'>

                3. <i id='L8NLT'><tr id='L8NLT'><dt id='L8NLT'><q id='L8NLT'><span id='L8NLT'><b id='L8NLT'><form id='L8NLT'><ins id='L8NLT'></ins><ul id='L8NLT'></ul><sub id='L8NLT'></sub></form><legend id='L8NLT'></legend><bdo id='L8NLT'><pre id='L8NLT'><center id='L8NLT'></center></pre></bdo></b><th id='L8NLT'></th></span></q></dt></tr></i><div id='L8NLT'><tfoot id='L8NLT'></tfoot><dl id='L8NLT'><fieldset id='L8NLT'></fieldset></dl></div>
                4. <legend id='L8NLT'><style id='L8NLT'><dir id='L8NLT'><q id='L8NLT'></q></dir></style></legend>
                    <tfoot id='L8NLT'></tfoot>

                    • <bdo id='L8NLT'></bdo><ul id='L8NLT'></ul>