[英]Swift 3 multiple gestureRecorgnizer SWRevealController
I have two gestureRecognizer I want to use. 我有两个要使用的gestureRecognizer。
1) Tap to close side menu (SWRevealController) 1)点击关闭侧面菜单(SWRevealController)
2) Tap view to dismiss keyboard 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)
}
Having both of these lines together, the dismiss keyboard gestureRecognizer trumps the revealViewController. 将这两条线放在一起,关闭键盘的手势手势识别器胜于revealViewController。 How can I combine this this use both gestures together?
如何将两个手势结合起来使用?
Make condition in LoginController.dismissKeyboard
method. 在
LoginController.dismissKeyboard
方法中创建条件。
check if isKeyboard
is open, then close it. 检查
isKeyboard
是否打开,然后将其关闭。 Otherwise close the (SWRevealController) sidemenu. 否则,请关闭(SWRevealController)侧面菜单。
For check keyboard is open or not you can use post notification of UIKeyboardWillShowNotification
and UIKeyboardWillHideNotification
methods. 对于检查键盘是否打开,您可以使用
UIKeyboardWillShowNotification
和UIKeyboardWillHideNotification
方法的后期通知。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.