使用push方法后关闭viewController

时间:2018-02-27 11:58:01

标签: ios swift uiviewcontroller

我使用此函数来推送一个新的viewController:

func goToPasscodeSetupVC() {
    let storyboard = UIStoryboard(name: "PassCode", bundle: nil)
    let viewController = storyboard.instantiateViewController(withIdentifier: "passcodeSetupVC") as! PasscodeSetupVC
    self.navigationController?.pushViewController(viewController, animated: true)
}

但是,当我使用新的viewController时,我想要忽略前一个,以便我无法通过轻扫手势触及它。

2 个答案:

答案 0 :(得分:0)

您可以使用它来禁用滑动后退手势。

self.navigationController?.interactivePopGestureRecognizer?.isEnabled = false

答案 1 :(得分:0)

您可以尝试使用setViewControllers代替pushViewController

    let storyboard = UIStoryboard(name: "PassCode", bundle: nil)
    let viewController = storyboard.instantiateViewController(withIdentifier: "passcodeSetupVC") as! PasscodeSetupVC
    self.navigationController?.setViewControllers([viewController], animated: true)