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

        • <bdo id='OprFu'></bdo><ul id='OprFu'></ul>
      1. <tfoot id='OprFu'></tfoot>
      2. <small id='OprFu'></small><noframes id='OprFu'>

        <legend id='OprFu'><style id='OprFu'><dir id='OprFu'><q id='OprFu'></q></dir></style></legend>
      3. 调用 popViewControllerAnimated 两次

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

          <tfoot id='w6G52'></tfoot>
            <tbody id='w6G52'></tbody>

            1. <small id='w6G52'></small><noframes id='w6G52'>

                <bdo id='w6G52'></bdo><ul id='w6G52'></ul>
                  本文介绍了调用 popViewControllerAnimated 两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个 UINavigationController,上面有一系列 UIViewControllers.在某些情况下,我想准确地弹出两个级别.我以为我可以通过连续两次调用 popViewControllerAnimated 来做到这一点,但事实证明,我第二次调用它时,它没有弹出任何东西,而是返回 NULL.我是否需要存储对目标 VC 的引用并改为调用 popToViewControllerAnimated?我可以这样做,但它会使我的代码复杂化,因为我必须在将 VC 推入堆栈时传递 UIViewController*.

                  I've got a UINavigationController with a series of UIViewControllers on it. Under some circumstances, I want to pop back exactly two levels. I thought I could do it by calling popViewControllerAnimated twice in a row, but it turns out that the second time I call it, it's not popping anything and instead returning NULL. Do I need to store a reference to my destination VC and call popToViewControllerAnimated instead? I can do that, but it complicates my code since I'd have to pass the UIViewController* around as I'm pushing VCs onto the stack.

                  以下是相关片段:

                  UIViewController* one = [self.navigationController popViewControllerAnimated:YES];
                  if (...) {
                      // pop twice if we were doing XYZ
                      UIViewController *two = [self.navigationController popViewControllerAnimated:YES];
                      // stored in "one" and "two" for debugging, "two" is always 0 here.
                  }
                  

                  我在这里做了什么奇怪的事情吗?我想写惯用的代码,所以如果正确"的方式是调用 popToViewControllerAnimated,或者完全是别的什么,我会很乐意改变它.

                  Am I doing something weird here? I want to write idiomatic code, so if the "right" way is to call popToViewControllerAnimated, or something else entirely, I'll happily change it.

                  推荐答案

                  在这种情况下,您需要像这样弹出导航控制器中的特定视图控制器:

                  In this case you would need to pop back to a specific viewcontroller in the navigationController like so:

                  [self.navigationController popToViewController:[[self.navigationController viewControllers] objectAtIndex:2] animated:YES];
                  

                  该代码将弹出到 navigationController 堆栈上的第三个视图控制器.

                  That code would pop to the third viewcontroller on the navigationController's stack.

                  这篇关于调用 popViewControllerAnimated 两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 Swift 中的 Nav Controller 中弹出 2 个视图控制器 下一篇:为什么 ARC 在 popViewController 之后不释放内存

                  相关文章

                • <tfoot id='QFeWt'></tfoot>

                  1. <small id='QFeWt'></small><noframes id='QFeWt'>

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

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