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

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

        以编程方式定义新的导航控制器顺序/堆栈?

        时间:2023-06-13

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

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

                  本文介绍了以编程方式定义新的导航控制器顺序/堆栈?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个 NavigationController,其中嵌入了以下 VC:VC1 -> VC2 -> VC3 -> VC4 -> VC5.我的问题是,当我从 VC5 切换时(编辑完成后),我将您送回 VC3,但我想以编程方式将 VC4 和 VC5 从堆栈中抛出,即当用户被送回 VC3 时,我想要返回" 在 navagitionBar 中将您带到 VC2(而不是您真正来自的 VC5).

                  I have a NavigationController that the following VC's are embedded in: VC1 -> VC2 -> VC3 -> VC4 -> VC5. My problem is that when I segue from VC5 (after editing is completed), I send you back to VC3, but I want to programmatically throw VC4 and VC5 off the stack, i.e. when the user is sent back to VC3, I want "back" in the navagitionBar to take you to VC2 (and not VC5 where you really came from).

                  这在 IOS 中经常出现,您想在其中编辑模型,然后将它们发送回 tableView/Collection 视图,但由于编辑完成,您不再希望在导航堆栈中编辑 viewControllers它对用户体验太混乱了.

                  This comes up a lot in IOS, where you want to edit the model, then send them back to the tableView/Collection view, but since editing is done, you don't want the editing viewControllers in the navigation stack anymore as its too confusing of UX.

                  在下面的截图中,右上角的VC是VC5: 通过 self.performSegueWithIdentifier("backToPins" 连接到 PinViewController (VC3),发件人:自己)

                  In the screenshot below, the VC on the top right is VC5: which is segued back to the PinViewController (VC3) via self.performSegueWithIdentifier("backToPins", sender: self)

                  我该怎么做?

                  推荐答案

                  不要使用 segue 回来(pop).

                  don't use segue to come back (pop).

                  您应该使用 popToViewController 并传递特定的 viewcontroller 作为参数来弹出该 viewcontroller.

                  you should use popToViewController and pass specific viewcontroller as argument to pop that viewcontroller.

                  例如,如果您想在五个视图控制器中使用第三个视图控制器,那么您可以执行以下操作.您可以将视图控制器数组中的索引更改为不同的视图控制器.

                  for example if you want to go on 3rd view controller out of five then you can do something like below. you can just change index from viewcontroller array to go different view controller.

                  let viewControllers: [UIViewController] = self.navigationController!.viewControllers as [UIViewController];
                  self.navigationController!.popToViewController(viewControllers[viewControllers.count - 3], animated: true);
                  

                  如果您使用 segue,则意味着您将新的视图控制器添加(推送)到导航堆栈.在您的示例中,您在达到第 5 个视图后的堆栈就像,

                  If you are using segue that means you add (push) new viewcontroller to navigation stack. in your example your stack after reaching 5th view is like,

                  VC1 - VC2 - VC3 - VC4 - VC5(栈顶)

                  现在如果你执行egue回到VC3那么堆栈应该是这样的,

                  now if you performsegue to go back to VC3 then stack should be like this,

                  VC1 - VC2 - VC3 - VC4 - VC5 - VC3(栈顶)

                  如果你弹出到 VC3,那么你的堆栈就像,

                  and if you pop to VC3 then your stack is like,

                  VC1 - VC2 - VC3(栈顶).

                  所以 pop viewcinrollers 回去不要使用 segue

                  so pop viewcintrollers to go back don't use segue

                  希望这会有所帮助:)

                  这篇关于以编程方式定义新的导航控制器顺序/堆栈?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:iOS:“单向"的最佳实践导航控制器? 下一篇:如何更改选中和未选中的标签栏图像颜色

                  相关文章

                  <tfoot id='HOCH6'></tfoot>

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

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

                      • <bdo id='HOCH6'></bdo><ul id='HOCH6'></ul>
                    1. <legend id='HOCH6'><style id='HOCH6'><dir id='HOCH6'><q id='HOCH6'></q></dir></style></legend>