Ios 类型';UITextField';没有成员';textDidBeginEditingNotification';
Swift 4.1出现以下错误 类型“UITextField”没有成员“textDidBeginEditingNotification” 类型“UITextField”没有成员“textDidChangeNotification” 我的错误代码Ios 类型';UITextField';没有成员';textDidBeginEditingNotification';,ios,swift,xcode,notifications,Ios,Swift,Xcode,Notifications,Swift 4.1出现以下错误 类型“UITextField”没有成员“textDidBeginEditingNotification” 类型“UITextField”没有成员“textDidChangeNotification” 我的错误代码 override open func draw(_ rect: CGRect) { super.draw(rect) self.drawLine() NotificationCenter.default.addObse
override open func draw(_ rect: CGRect) {
super.draw(rect)
self.drawLine()
NotificationCenter.default.addObserver(self, selector: #selector(didBeginTextEdit), name: UITextField.textDidBeginEditingNotification, object: self)
NotificationCenter.default.addObserver(self, selector: #selector(didTextEditFinish), name: UITextField.textDidChangeNotification, object: self)
}
Xcode中的Autocomplete可能也会发现这一点,但您的通知名称是错误的。请尝试
UITextFieldTextDidBeginEditingNotification
和uitextfieldtextdidchangennotification
问题中的代码适用于Swift 4.2。