Get tableView:heightForRowAtIndexPath: to happen after tableView:cellForRowAtIndexPath:?

前端 未结 3 683
無奈伤痛
無奈伤痛 2020-12-14 20:58

I\'ve got some UITableViewCells that need to change their height depending on the length of the strings inside. I\'m calculating the necessary height inside tableView:

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-14 21:06

    My solution was to call the tableView:cellForRowAtIndexPath: inside the implementation of tableView:heightForRowAtIndexPath: as following

    - (CGFloat)tableView:(UITableView *)aTableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
       [self tableView:aTableView cellForRowAtIndexPath:indexPath];
       return headerHeight;
    }
    

提交回复
热议问题