Get height of UITableView without scroll bars

前端 未结 4 1675
野趣味
野趣味 2021-01-31 02:25

I need to get the full height of a UITableView (i.e. the height at which there would be nothing more to scroll). Is there any way to do this?

I\'ve tried

4条回答
  •  忘掉有多难
    2021-01-31 03:31

    Try the contentSize method, which is inherited from UITableView’s superclass, UIScrollView. However, you may find that contentSize returns an incorrect or out of date value, so you should probably call layoutIfNeeded first to recalculate the table’s layout.

    - (CGFloat)tableViewHeight
    {
       [tableView layoutIfNeeded];
       return [tableView contentSize].height;
    }
    

提交回复
热议问题