UITextField代理事件

来源:互联网 发布:五笔vb是什么字 编辑:程序博客网 时间:2024/06/01 20:57

UITextField的代理事件一共有7种,一般对UITextField进行高级使用时,都是监听它的代理事件来做出相应的操作。

#pragma mark - UITextFieldDelegate//是否允许输入 经常用于限定输入长度- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{    NSLog(@"11111");    return YES;}//开始编辑- (void)textFieldDidBeginEditing:(UITextField *)textField{    NSLog(@"22222");    [self becomfirstView];}//是否允许编辑结束 一般不使用- (BOOL)textFieldShouldEndEditing:(UITextField *)textField{    NSLog(@"333333");    return YES;}//结束编辑- (void)textFieldDidEndEditing:(UITextField *)textField{    NSLog(@"4444444");    [self nofirstView];}//可以得到用户输入的字符对其操作 e.g.限制长度- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{    NSLog(@"555555");    return YES;}//当用户全部清空的时候的时候 会调用- (BOOL)textFieldShouldClear:(UITextField *)textField{    NSLog(@"6666666");    return YES;}//键盘按钮return键按下- (BOOL)textFieldShouldReturn:(UITextField *)textField{    NSLog(@"77777");    return YES;}
0 0
原创粉丝点击