Change UITableViewCell Height on Orientation Change

前端 未结 2 1782
一整个雨季
一整个雨季 2021-02-08 03:25

I have a UITableView with cells containing variable-height UILabels. I am able to calculate the minimum height the label needs to be using sizeWithFont:constrainedToSize:l

2条回答
  •  闹比i
    闹比i (楼主)
    2021-02-08 04:15

    Your UITableViewController can implement the tableView:heightForRowAtIndexPath: method to specify the row height for a particular row, and it can look at the current orientation ([[UIDevice currentDevice] orientation]) to decide what height to return.

    To make sure tableView:heightForRowAtIndexPath: gets called again when the orientation changes, you'll probably need to detect the orientation change as described in this question, and call [tableView reloadData].

提交回复
热议问题