我有一个自定义UIControl,并希望为特定的UIControlEvents添加目标。所以我在自定义UIControl中指定了一个协议和一个委托变量:
protocol FieldEventHandlerDelegate {
func willSelectField(sender:Field)
}
class Field {
var delegate:FieldEventHandlerDelegate?
func setupEventHandlers(withDelegate del:FieldEventHandlerDelegate) {
delegate = del
self.addTarget(delegate, action: #selector(willSelectField(sender:)), for: .touchUpInside)
}
但是Xcode给了我错误:Use of unresolved identifier 'willSelectField(sender:)'