how to obtain the UITableViewCell within heightForRowAtIndexPath?

后端 未结 6 699
孤城傲影
孤城傲影 2020-12-24 12:19

How does one obtain the UITableViewCell when within the heightForRowAtIndexPath method, i.e. given the indexPath?

(then I could access the

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-24 13:20

    You can use the tableview's delegate instead of the tableView itself.

    id cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
    

    Check the answer here

    UPDATED

    In new iOS versions and using correct auto constraints you don't need to reference the cell anymore to calculate the cell's height.

    Check here

    https://www.raywenderlich.com/129059/self-sizing-table-view-cells

提交回复
热议问题