iOS8 - constraints ambiguously suggest a height of zero

前端 未结 18 1811
青春惊慌失措
青春惊慌失措 2020-12-02 14:15

Has anyone got any idea how to debug this?

Warning once only: Detected a case where constraints ambiguously suggest a height of zero for a tableview c

18条回答
  •  北海茫月
    2020-12-02 14:37

    There are two important things happening here, I think.

    1) It's super easy to make the constraints wrong if you're ctrl+dragging. So, double check that you have it done correctly. Best to use the tray on the left side of the screen to draw these constraints.

    2) Instead of specifying the estimatedRowHeight in ViewDidLoad or somewhere else, use the delegate method

    override func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {}
    

    This fixed the problem right away for me.

提交回复
热议问题