限制 UITextField 的输入长度

2015-11-05 0 383
限制 UITextField 的输入长度
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range 
                            replacementString:(NSString *)string 
{
    //Check that response should be a maximum 5 characters
    if ([string length] > 0) {
        return [textField.text length] < 5;
    }
    return YES;
}

-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    if([string length]>0{
        return [textField.text length]<5;  //这里报错,textField没有 text属性?
    }
       return YES;
}

遇见资源网 objective-c 限制 UITextField 的输入长度 http://www.ox520.com/18115.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务