为什么我的应用程序在启动时会崩溃,但没有输入任何代码导致任何事情?
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let tap: UITapGestureRecognizer = UITapGestureRecognizer (target: self, action: #selector(ViewController.keyvoardDismiss))
view.addGestureRecognizer(tap)
}
@objc func keyvoardDismiss() {
view.endEditing(true)
}
}
答案 0 :(得分:2)
keyvoardDismiss不是类方法,请使用
#selector(keyvoardDismiss)