Is it possible to have differing heights in a UITableView Cell when I use several different ways of displaying the cell?

后端 未结 11 1297
一整个雨季
一整个雨季 2020-12-21 19:25

I\'ve spent several days trying to figure this out, but there doesn\'t seem to be a solution. I have a very basic UITableView cell with two labels in it. One of them will be

11条回答
  •  攒了一身酷
    2020-12-21 20:02

    For this you need to make use of Self sizing table view cell i.e. table view itself calculates height required for each cells to display it's content it can be achieved in two lines of code:

    Step1: set estimate height for table view tableView.estimatedRowHeight = 33.0 step2: set tableView's row height to UITableViewAutomaticDimension tableView.rowHeight = UITableViewAutomaticDimension

    Here is the tutorial for detail description http://www.appcoda.com/self-sizing-cells/

提交回复
热议问题