import UIKit
class AViewController: UIViewController {}
class BViewController: UIViewController {}
class CViewController: UIViewController {}
let a = AViewController()
let b = BViewController()
let c = CViewController()
let nav = UINavigationController(rootViewController: a)
nav.pushViewController(b, animated: true)
nav.pushViewController(c, animated: true)
// Option 1
nav.popToRootViewController(animated: true)
// Option 2
nav.popToViewController(a, animated: true)
2条答案
按热度按时间hts6caw31#
如果您使用的是UINavigationController,则可以使用popToRootViewController
f8rj6qna2#
最简单的方法是使用
UINavigationController
:从A -〉B(A中的代码):从B -〉C(这段代码在B中):
从C -〉A(C中的代码):