Рассмотрим мою реализацию:
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
switch (theSection) {
case 0:
if (indexPath.row ==6) //the row you need to check for height (if any)
{
if([yourString length]<=35) // if less than 35 chars, just return a basic size of 50
{
return 50;
}
CGSize detailSize = [yourString sizeWithFont:[UIFont systemFontOfSize:20]constrainedToSize:CGSizeMake(270, 4000)lineBreakMode:UILineBreakModeWordWrap];
return detailSize.height;
}
надеюсь, что это поможет, чтобы помочь вашему пониманию, вы, возможно, захотите взглянуть на 'sizeWithFont', чтобы понять, что он делает, чтобы вернуть размер.