使用.editingDidEnd
选项添加目标与方法textFieldDidEndEditing
有什么区别?
@IBOutlet weak var textField: UITextField! {
didSet {
// check when textField editing ends
textField.addTarget(self,
action: #selector(titleDidChange(_:)),
for: .editingDidEnd)
}
}
VS。
func textFieldDidEndEditing(_ textField: UITextField) {
// user has resigned responder
}