1

I use actually this code (set maximum 4 characters) :

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
    NSUInteger newLength = [self.messageText.text length] + [string length] - range.length;

    return (newLength > 4) ? NO : YES;
}

But emoji are considered like 2 characters.

How can I set the maximum amount of characters in a UITextField that contains emoji and text ?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • Also see http://stackoverflow.com/q/14928995/1226963 for a similar answer made as a nice `NSString` category method. – rmaddy Jan 28 '15 at 01:01

0 Answers0