Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get height of UITableView without scroll bars

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 [tableView sizeThatFits:CGSizeZero], but that only returns a 0x0 CGSize.

like image 279
igul222 Avatar asked Mar 27 '10 03:03

igul222


1 Answers

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; } 
like image 57
Todd Yandell Avatar answered Oct 06 '22 00:10

Todd Yandell