[英]Swift 3 multiple gestureRecorgnizer SWRevealController
我有兩個要使用的gestureRecognizer。
1)點擊關閉側面菜單(SWRevealController)
2)點擊視圖以關閉鍵盤
override func viewDidLoad() {
super.viewDidLoad()
menuBtn.addTarget(self.revealViewController(), action: #selector(SWRevealViewController.revealToggle(_:)), for: .touchUpInside)
self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
self.view.addGestureRecognizer(self.revealViewController().tapGestureRecognizer())
let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(LoginController.dismissKeyboard))
self.view.addGestureRecognizer(tap)
}
將這兩條線放在一起,關閉鍵盤的手勢手勢識別器勝於revealViewController。 如何將兩個手勢結合起來使用?
在LoginController.dismissKeyboard
方法中創建條件。
檢查isKeyboard
是否打開,然后將其關閉。 否則,請關閉(SWRevealController)側面菜單。
對於檢查鍵盤是否打開,您可以使用UIKeyboardWillShowNotification
和UIKeyboardWillHideNotification
方法的后期通知。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.