在您的 tableview 委托中执行此操作:
- (CGFloat)tableView:(UITableView *)tableView1 heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
CGSize maximumSize = CGSizeMake(480.0,1000.0); // Put appropriate required height and width.
NSString *dateString = [NSString stringWithFormat:@"%@",yourString];
UIFont *dateFont = [UIFont fontWithName:@"Helvetica" size:14];
CGSize dateStringSize = [dateString sizeWithFont:dateFont
constrainedToSize:maximumSize
lineBreakMode:UILineBreakModeWordWrap];
return dateStringSize.height;
}
此代码将为您的单元格设置适当的高度。然后在你的 cellForRowAtIndexPath 函数中。保留此代码:
comment.adjustFontSizeToFitWidth = NO;
comment.numberOfLines = 0;
comment.lineBreakMode = UILineBreakModeCharacterWrap