[英]How to disable UINavigation swipe pop gesture only for UITabbarController?
我正在開發 iOS 應用程序,我使用的是 Swift 4.2 和 Xcode 10.3。
我必須啟用滑動手勢以在UINavigationController
彈出UIViewController
,這是我的應用程序屏幕流程:
流程說明:
UINavigationController
並且啟動畫面在rootViewController
。UITabbarController
。tabBarController
每個包含navigationController
。UITabbarController
推送它。我正在使用以下代碼使用滑動手勢啟用屏幕彈出。 我在啟動畫面中添加了這一行:
override func viewWillAppear(_ animated: Bool) {
self.navigationController?.interactivePopGestureRecognizer?.delegate = nil
}
這個滑動手勢導航彈出窗口工作正常,但我只想為標簽欄控制器禁用它。 當我向左滑動到選項卡控制器時,它會彈出我們顯示“登錄”和“注冊”按鈕的屏幕。
所以我的問題是如何禁用導航堆棧中某些屏幕的滑動手勢彈出。
您需要在所需的 VC 中禁用“interactivePopGestureRecognizer”,以免在 viewDidLoad 中添加此代碼段
navigationController?.interactivePopGestureRecognizer?.isEnabled = false
如果您想在其他 VC 中啟用,請確保使用 -
navigationController?.interactivePopGestureRecognizer?.isEnabled = true
試一試!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.