swift 返回指定界面

// 跳转指定控制器
    func jumpController() {
        
        // 跳转指定控制器
        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?.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 返回指定界面)