我设置了一个UITextView
奇怪的行为。如果我将它的内容设置为很长text
,它会在边界处正确地打破它,但是如果内容是单行的,它会在最后一个单词之前自动打破它,即使它适合一行。它创造了最少的线条。
我在网上找不到这个问题,所以我不得不问。
这里是设置UITextView
Message * displayedMessage = [messages objectAtIndex:indexPath.row];
UIFont * messageFont = [UIFont fontWithName:@"Helvetica" size:13];
CGSize messageSize = [displayedMessage.content sizeWithFont:messageFont constrainedToSize:CGSizeMake(240.f, 3000.f) lineBreakMode:UILineBreakModeWordWrap];
UITextView * messageTextView = [[UITextView alloc] initWithFrame:CGRectMake(46.f, 0.f, messageSize.width, messageSize.height + 25)];
messageTextView.backgroundColor = [UIColor clearColor];
messageTextView.font = messageFont;
messageTextView.editable = NO;
messageTextView.scrollEnabled = NO;
messageTextView.contentInset = UIEdgeInsetsZero;
messageTextView.textColor = [UIColor blackColor];
[messageTextView setDataDetectorTypes:UIDataDetectorTypeAll];
messageTextView.text = displayedMessage.content;
[cell addSubview:messageTextView];