本文由我司收集整编,推荐下载,如有疑问,请与我司联系如果文本中包含一个长字符串,则sizeWithFont不会为UITextView
提供正确的高度
如果文本中包含一个长字符串,则sizeWithFont不会为UITextView提供正确的高度[英]sizeWithFont doesn’t give correct height for UITextView if there is a long string in the text being wrapped Is there a way to get the correct size of an NSString using:
 是否有一种方法可以使用以下方法获得NSString的正确大小:
 - (CGSize)sizeWithFont:(UIFont *)font forWidth:(CGFloat)width lineBreakMode:(UILineBreakMode)lineBreakMode that doesnt get thrown off by 2 or 3 hundred character strings. At the moment if I try to use this method on these long strings it incorrectly calculates them and I end up with lots of whitespace at the bottom of the UITextView.
 它不会被2或3百个字符串所抛弃。目前,如果我尝试在这些长字符串上使用这个方法,它会错误地计算它们,并且在UITextView的底部会有很多空格。
  I’ve tried using UILineBreakModeWordWrap and UILineBreakModeCharacterWrap.  我试过用UILineBre
akModeWordWrap和UILineBreakModeCharacterWrap。字符串长度工具
  the resizing is being done in
 正在进行调整
 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { CGFloat result = 44.0f; NSString* text = nil; CGFloat width = 0; CGFloat tableViewWidth; CGRect bounds = [UIScreen mainScreen].bounds; tableViewWidth = bounds.size.width; CGSize textSize = { width, 20000.0f };  CGSize size = [text sizeWithFont:[UIFont systemFontOfSize:10.0f] constrainedToSize:textSize lineBreakMode:UILineBreakModeWordWrap]; size.height += 50.0f;  result = MAX(size.height, 44.0f+30.0f);  return result; 21
 UITextView is not exactly like a UILabel wrapped in a UIScrollView. It has line

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。