swift textfield editing
UITextField and UITextField Delegate using swift in iOS
ios – How do I check when a UITextField changes? – Stack Overflow
结果UITextFieldDelegate中没有找到textFieldDidChange
然后最后用:
phoneTextField.addTarget(self, action: "textFieldDidChange:", forControlEvents: UIControlEvents.EditingChanged) func textFieldDidChange(textField: UITextField) { print("textFieldDidChange textField=\(textField)") updateSmsCodeButton() } |
即可。
[总结]
想要监控文本框在输入文字时的事件,可以用:
phoneTextField.addTarget(self, action: "textFieldDidChange:", forControlEvents: UIControlEvents.EditingChanged) func textFieldDidChange(textField: UITextField) { print("textFieldDidChange textField=\(textField)") updateSmsCodeButton() } |
转载请注明:在路上 » [已解决]swift实现文本框输入期间执行动作