objective-c - iOS textview needs to wrap multiple lines like WeChat and only output once
过去多啦不再A梦
过去多啦不再A梦 2017-05-02 09:35:34
0
0
691

iOS textview needs to wrap multiple lines like WeChat and only output once.
For example:
123

31

123
will eventually become:
123

31

123, is there any solution?
I wrote a loop but I can only remove the first one between 123 and 31, but there is nothing I can do about the rest

int x = 0 ;
for (int i = 0; i < _info.length; i ++) {
    if ([[_info substringWithRange:NSMakeRange(i, 1)] isEqualToString:@"\n"]) {
        x ++;
    }
    else{
        if (x > 1) {
            _info = [_info stringByReplacingCharactersInRange:NSMakeRange(i - x, x) withString:@"\n"];
            x = 0;
        }
    }
}

还有一个小要求就是textview统计字数的时候把换行也算上,要加上一行能打出的字的数量,谢谢。
过去多啦不再A梦
过去多啦不再A梦

reply all(0)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template