美文网首页
textField的代理方法

textField的代理方法

作者: 七里田间的守望者 | 来源:发表于2016-12-15 10:47 被阅读49次
    #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;  
    }  
    

    相关文章

      网友评论

          本文标题:textField的代理方法

          本文链接:https://www.haomeiwen.com/subject/yqnwmttx.html