- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
//监听通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textChange) name:UITextFieldTextDidChangeNotification object:self.accountField];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textChange) name:UITextFieldTextDidChangeNotification object:self.pwdField];
}
//移除监听
- (void)dealloc
{
[[NSNotificationCenter defaultCenter]removeObserver:self];
}
/**
* 文本框文字发生改变的时候调用
*/
- (void)textChange
{
self.loginBtn.enabled = (self.accountField.text.length && self.pwdField.text.length);
}
iOS 监听文本框的改变 代码片段
最新推荐文章于 2019-05-02 19:40:13 发布