textField通知事件iOS
- 作者: 安静祝福她
- 来源: 51数据库
- 2022-08-17
//设置通知
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector (textFieldChange:)
name:UITextFieldTextDidChangeNotification object:_commentTextField];
//实现通知方法
- (void) textFieldChange:(NSNotification *)notification{
UITextField *textField=[notification object];
}
/*****************************************************************************/
_textField = [[UITextField alloc]initWithFrame:CGRectMake(5, 10, SCREEN_WIDTH-10, 40)];
[_textField addTarget:self action:@selector(textFieldDidChangee:) forControlEvents:UIControlEventEditingChanged];
//点击方法
- (void)textFieldDidChangee:(UITextField *)textField
{
NSLog(@"333%@",textField);
}
推荐阅读
