繁体   English   中英

Swift 3多重手势记录器SWRevealController

[英]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)侧面菜单。

对于检查键盘是否打开,您可以使用UIKeyboardWillShowNotificationUIKeyboardWillHideNotification方法的后期通知。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM