我有一个UITableView
的原型单元格,我使用以下代码计算其高度:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
[cell layoutIfNeeded];
CGSize size = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
return size.height + 1;
}
我在cellForRowAtIndexPath
内出列的单元格中只有一个UILabel
,并且我将NSAttributedString设置为其文本。
问题是,当我在iOS 7.1模拟器上运行时,一切都很完美。但是,当我在iOS 8.4模拟器上运行它时,会返回一个更大的高度,因此单元格底部有足够的空间。可能是什么导致了这个?任何评论或建议将不胜感激。