Flipkart Search

Search This Blog

Wednesday, May 12, 2010

Limit Characters in UITextField

Here is a simple delegate method to limit the characters in UITextfield :-

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
        NSUInteger newLength = [textField.text length] + [string length] - range.length;
        return (newLength > 8) ? NO : YES;

1 comment:

Mobile Development said...

Wow another useful post. You guys have really helped fellow iPhone developers. Do you offer any advertising opportunities?