NSMutableString* str_attachMent = [NSMutableString stringWithFormat:@"附件(%ld):",attachedCount];
for ( int i = 0 ; i < attachedCount ; i++) { FileInfo *fileInfo = (FileInfo*)mailInfo.attachedArr[i]; if (i < mailInfo.attachedCount - 1) { [str_attachMent appendFormat:@"%@;",fileInfo.fileName]; }else { [str_attachMent appendString:fileInfo.fileName]; } }
最后str_attachMent得到拼装好的字符串是如下内容:
附件(9): 404.HTML;BLOG.HTML;BLOG_SINGLE.HTML;CONTACT.HTML;INDEX.HTML;LOGIN.HTML;MEN.HTML;REGISTER.HTML;SINGLE.HTML
可以把内容复制到记事本上面试验下,为什么强行被换行了,而且我是没办法把404这行移到附件(9):后面
[str_attachMent stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; 移除空格和换行也没有作用.
我估计是拼装内容的问题,但是这个问题没有办法解决么.
It is not a forced career change. During typesetting, the system will
"404.HTML;BLOG.HTML;BLOG_SINGLE.HTML;CONTACT.HTML;INDEX.HTML;LOGIN.HTML;MEN.HTML;REGISTER.HTML;SINGLE.HTML" Zu is a word. When it is displayed, the current line where "Attachment (9):" is located cannot display it completely, so it automatically jumps to the next line for display, unless the text box you display is wide enough. Just like if you directly print this sentence like this when posting a question, it will also be displayed in a new line,
Attachment (9): 404.HTML;BLOG.HTML;BLOG_SINGLE.HTML;CONTACT.HTML;INDEX.HTML;LOGIN. HTML;MEN.HTML;REGISTER.HTML;SINGLE.HTML
But if you add a space after each semicolon, the effect is like this:
Attachment (9): 404.HTML; BLOG.HTML; BLOG_SINGLE.HTML; CONTACT.HTML; INDEX.HTML; LOGIN.HTML; MEN.HTML; REGISTER.HTML; SINGLE.HTML
Because you added spaces to distinguish each semicolon as a whole, so it will not appear during typesetting This question of yours.
For UITextView, various UI controls that process text will change the layout of the text, which can be solved by using NSMutableAttributedString.
NSString* str = [NSString stringWithFormat:@"Attachment (%ld):",str1];