gpt4 book ai didi

ios - 如何在 IOS 中弹出堆栈?

转载 作者:行者123 更新时间:2023-11-28 18:57:53 25 4
gpt4 key购买 nike

我正在构建一个 iOS 应用程序。

下面解释了我在做什么-

  1. 有 3 个 ViewController,分别命名为 A、B、C。
  2. 我通过按钮点击功能转到 A 到 B,然后转到 C。
  3. 我必须在所有三个 ViewController(A、B、C)上实现导航 Controller 。
  4. 现在,当我按下导航 Controller 的后退键时,接下来的堆栈是 C -> B -> A。这是默认行为。

我需要的是堆栈操作应该像 - C -> A 一样执行。

为此,我必须从堆栈中弹出 B。如何从堆栈中弹出 B。

最佳答案

如果你的意图是总是回到堆栈上的第一个 View Controller ,你可以使用

[self.navigationController popToRootViewControllerAnimated:YES];

如果你想弹出 X 个 View Controller ,检查来自 SO 的这个答案:How do I pop two views at once from a navigation controller?

关于ios - 如何在 IOS 中弹出堆栈?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30304026/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com