美文网首页
限制输入字符串的长度

限制输入字符串的长度

作者: iOS乐乐 | 来源:发表于2017-05-20 14:59 被阅读0次

//获取文本框字符的长度

-(NSUInteger) unicodeLengthOfString: (NSString *) text {
    NSUInteger asciiLength = 0;
    for (NSUInteger i = 0; i < text.length; i++) {
        unichar uc = [text characterAtIndex: i];
        asciiLength += isascii(uc) ? 1 : 2;
    }
    return asciiLength;
}

相关文章

网友评论

      本文标题:限制输入字符串的长度

      本文链接:https://www.haomeiwen.com/subject/qplpxxtx.html