如何在IOS中弹出堆栈? [英] How to Pop stack in IOS?

查看:34
本文介绍了如何在IOS中弹出堆栈?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am building an iOS application.

我正在做的事情解释如下 -

What I am doing is explained below -

  1. 有 3 个名为 A、B、C 的 ViewController.
  2. 对于按钮点击功能,我从 A 到 B,然后到 C.
  3. 我必须在所有三个 ViewController(A、B、C)上实现导航控制器.
  4. 现在,当我按下导航控制器的背面时,后面的堆栈是 C -> B -> A.这是默认行为.

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

What I need is the stack operation should be perform like - C -> A.

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

For this I have to Pop B from the stack. How can I Pop the B from stack.

推荐答案

如果你的意图是总是回到栈上的第一个视图控制器,你可以使用

If your intention is to always go back to the first view controller on the stack, you can use

[self.navigationController popToRootViewControllerAnimated:YES];

如果您想弹出 X 个视图控制器,请查看以下答案:如何从导航控制器一次弹出两个视图?

If you want to pop X number of view controllers, check this answer from SO: How do I pop two views at once from a navigation controller?

这篇关于如何在IOS中弹出堆栈?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆