#pragma mark - textField delegate
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
NSLog(@"1");//输入文字时 一直监听
return YES;
}
-(void)textFieldDidBeginEditing:(UITextField *)textField
{
NSLog(@"2");// 准备开始输入 文本字段将成为第一响应者
}
-(void)textFieldDidEndEditing:(UITextField *)textField
{
NSLog(@"3");//文本彻底结束编辑时调用
}
-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
NSLog(@"4");//返回一个BOOL值,指定是否循序文本字段开始编辑
return YES;
}
-(BOOL)textFieldShouldClear:(UITextField *)textField
{
NSLog(@"5");// 点击‘x’清除按钮时 调用
return YES;
}
-(BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
NSLog(@"6");//返回BOOL值,指定是否允许文本字段结束编辑,当编辑结束,文本字段会让出第一响应者
return YES;
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
NSLog(@"7");// 点击键盘的‘换行’会调用
return YES;
}
网友评论