Autolayout is ignored in Custom UITableViewCell

前端 未结 2 908
孤街浪徒
孤街浪徒 2020-11-29 20:01

Despite having set constraints to all elements, including the vertical ones needed for the cell to calculate its height, auto-layout seems to be ignored: all cells are squee

相关标签:
2条回答
  • 2020-11-29 20:35

    I think the problem is that you are implementing :

    func tableView(_ tableView: UITableView, heightForRowAt indexPath: 
    IndexPath) -> CGFloat {
    
     return x
    }
    

    You need to remove this function inorder for the tableview to calculate its automatic height for cells.

    0 讨论(0)
  • 2020-11-29 20:37

    Auto-layout was ignored because both the prototype cell AND the UIView of the cell had been given the custom cell class in IB.

    Setting the UIView back to UIView class solved the problem.

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