Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView content height

I have a UITableView that is set to not enable scrolling, and it exists in a UIScrollView. I'm doing it this way as the design specs call for something that looks like a table view, (actually there are two of them side by side), and it would be much easier to implement tableviews rather than adding a whole bunch of buttons, (grouped table views).

Question is, I need to know how big to make the container view for the scrollview, so it scrolls the whole height of the table views. Once loaded, is there any way to find the height of a tableview? There is no contentView property like a scroll view, frame seems to be static, etc...

Any thoughts?

like image 352
mickm Avatar asked Oct 18 '11 00:10

mickm


1 Answers

Use

CGRect lastRowRect= [tableView rectForRowAtIndexPath:index_path_for_your_last_row];
CGFloat contentHeight = lastRowRect.origin.y + lastRowRect.size.height;

You can then use the contentHeight variable to set the contentSize for the scrollView.

like image 179
Andrei Stanescu Avatar answered Sep 24 '22 18:09

Andrei Stanescu