Ví dụ, tôi có 3 câu như @ "trước dài dài.", @ "Có một đứa trẻ.", @ "Bla bla bla" Và tôi đã thực hiện một phương pháp dưới đâyTại sao appendAttributedString hiển thị chuỗi được nối thêm trong một dòng mới?
- (void)appendText:(NSString*)text
{
NSMutableAttributedString *originalText = [[NSMutableAttributedString alloc] initWithAttributedString:_textView.attributedText];
NSAttributedString *appendText = [[NSAttributedString alloc] initWithString:text
attributes:@{NSForegroundColorAttributeName:DefaultTextColor}];
[originalText appendAttributedString:appendText];
_textView.attributedText = originalText;
}
Vì vậy, tôi Viện dẫn appendText 3 lần
[self appendText:@"Long long ago."];
[self appendText:@"There is a child."];
[self appendText:@"bla bla bla."];
kết quả tôi mong đợi là
Long long ago.There is a child.bla bla bla.
Nhưng đầu ra là
0.123.Long long ago.
There is a child.
bla bla bla
Tại sao appendAttributedString hiển thị chuỗi được nối thêm trong một dòng mới? Làm thế nào tôi có thể đặt các văn bản nối thêm trong một đoạn văn?
Cảm ơn bạn đã được trợ giúp.
Nó hoạt động giống như một quyến rũ. Cảm ơn, rmaddy. Bạn thực sự đã cứu mạng tôi. – echo
Gotta yêu rmaddy. –