How to get the size of a UITableView's content view?

后端 未结 4 976
无人共我
无人共我 2021-02-01 19:20

I would like to get the size of a UITableView\'s content view when the table is populated. Any suggestions on how to do this?

4条回答
  •  旧巷少年郎
    2021-02-01 19:57

    // Allows you to perform layout before the drawing cycle happens. 
    //-layoutIfNeeded forces layout early. So it will correctly return the size. 
    // Like dreaming before doing.
    
    [tableView layoutIfNeeded];
    
    
    CGSize tableViewSize=tableView.contentSize;
    

提交回复
热议问题