Dynamic UITableViewCell content does not expand cell

后端 未结 3 1771
天涯浪人
天涯浪人 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.

    0 讨论(0)
  • 2020-12-22 03:21

    In addition to Auto-Layout constraint
    try
    cell.contentView.LayoutIfNeeded statement in cellForRowIndexPath just before returning cell and HeightForRowAtIndexPath method

    0 讨论(0)
  • 2020-12-22 03:33

    If you're sure all your vertical constraints are set and correct top to bottom, try setting tableView.rowHeight = UITableViewAutomaticDimension explicitly.

    0 讨论(0)
提交回复
热议问题