swift 返回指定界面的几种方法
作者:
舟_e9ce | 来源:发表于
2019-06-05 10:34 被阅读0次// 跳转指定控制器
func jumpDesignatedController() {
// 方法一(跳转指定控制器)
let mineVC = MyAcountAuthViewController()
var targetVC : UIViewController!
for controller in self.navigationController!.viewControllers {
if controller.isKind(of: mineVC.classForCoder) {
targetVC = controller
}
}
if targetVC != nil {
self.navigationController?.popToViewController(targetVC, animated: true)
}
// 方法二(跳转根控制器)
self.navigationController?.popToRootViewController(animated: true)
// 方法三(返回到根界面的某个控制器)
self.navigationController?.tabBarController?.hidesBottomBarWhenPushed = false
self.navigationController?.tabBarController?.selectedIndex = 0 // (第一个控制器)
self.navigationController?.popToRootViewController(animated: true)
// 方法四(返回两级界面)
if (self.navigationController?.viewControllers.count)! >= 2 {
guard let vc = self.navigationController?.viewControllers[1] else { return }
self.navigationController?.popToViewController(vc, animated: true)
}
}
本文标题:swift 返回指定界面的几种方法
本文链接:https://www.haomeiwen.com/subject/dkdjxctx.html
网友评论