开发者

How to stop entering value in UITextField

开发者 https://www.devze.com 2023-03-17 02:34 出处:网络
How to stop entering value in UITextField if t开发者_如何学Gohe length is greater then 20 char.

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

精彩评论

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

关注公众号