[英]How to dismiss previous Viewcontroller after presenting new Viewcontroller using Swift?
[英]Dismiss a viewController after using a push method
我使用此功能來推送新的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時,我想關閉前一個,以便無法通過滑動手勢到達它。
您可以使用它禁用向后滑動手勢。
self.navigationController?.interactivePopGestureRecognizer?.isEnabled = false
您可以嘗試使用setViewControllers
而不是pushViewController
let storyboard = UIStoryboard(name: "PassCode", bundle: nil)
let viewController = storyboard.instantiateViewController(withIdentifier: "passcodeSetupVC") as! PasscodeSetupVC
self.navigationController?.setViewControllers([viewController], animated: true)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.