Dynamic UITableViewCell content does not expand cell

后端 未结 3 1800
天涯浪人
天涯浪人 2020-12-22 02:56

I have a storyboard with several different types of prototype cells with UILabels containing dynamic data. In my storyboard, the cell looks like this:

The U

3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-22 03:18

    It seems you have set your constraints correctly, just make sure that delegates are as below:

    -(CGFloat)tableView:(UITableView *)tableView
    estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
        return 44;
    }
    
    -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
       return UITableViewAutomaticDimension;
    }
    

    (If your constraints are set correctly from top to bottom)And that's it, you dont have to do anything else, auto layout will do its work smartly.

提交回复
热议问题