我有一个 UIButton
和一个 UITextField
,当按下按钮时,文本字段的内容字符串将等于:This is a test string
,在这种情况下,如何检测到此文本字段的内容已更改?
附注UITextField 的
委托(delegate)方法在这种情况下不起作用
更新:我希望此行为出现在 iOS 6+ 设备上。
最佳答案
您可以添加 UITextFieldTextDidChangeNotification
:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(textFieldChanged:)
name:UITextFieldTextDidChangeNotification
object:textField];
textField
(参数对象)是您的 UITextField。
selector
是您的方法,将在触发此通知时调用。
关于iphone - 当键盘未进行更改时检测 UITextField 内容的更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13952177/