只需使用swift 3选择器语法更改您的选择器语法,如下所示。
#selector(self.hideKeyboard)
The syntax for Selector has been changed in Swift 3. You don't need to add round brackets after selector name if there is no parameter in the selector.
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(hideKeyboard))
self.view.addGestureRecognizer(tapGesture)
For anyone looking for a solution can try this.
let tap = UITapGestureRecognizer(target: self, action: #selector(self.handleTap(_:)))
view.addGestureRecognizer(tap)
// function which is triggered when handleTap is called
func handleTap(_ sender: UITapGestureRecognizer) {
print("Hello World")
}
I know it's loo late to answer, but it can help others.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.