1.常見問題,
a.UILabel的高度自適應,
b.TableViewCell高度的自適應。
2.解決方案:UILabel高度的自適應, 首先是設定好label的約束。
UILabel屬性設置:
主要代碼包括2段:2個缺一不可
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewAutomaticDimension;
}
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 170;
}