开发者

How to stop entering value in UITextField

How to stop entering value in UITextField if t开发者_如何学Gohe length is greater then 20 char.

Programmatically.


try this

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string 
{
    //Set tag for a textfield
    if(textField.tag==10)
    {
        NSUInteger newLength = [textField.text length] + [string length] - range.length;
        return (newLength > 20) ? NO : YES;

    }
}


Set the maximum character length of a UITextField

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜