iOS8 - constraints ambiguously suggest a height of zero

前端 未结 18 1839
青春惊慌失措
青春惊慌失措 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:28

    Forcing a return height and estimated height made the warning disappear in my case.

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

    Another solution where you don't need the two overrides is simply to use self.tableView.rowHeight = 44; in your loadView or init method.

提交回复
热议问题