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;
}