views:

73

answers:

4

Hi all,

In my application , the tableview is having different types of custom cells with different heights. I want to put a view below this tableView, for which I need to calculate the table contentView height, how can I do it?

Earlier I used to do it like: (noOfRows * cell_height), but that was for static heights.

Thanx in advance.

A: 

a slightly ugly way..but should work..

tableView.backgroundView.frame.size.height
Jesse Naugher
It doesn't work for me.. :(
neha
A: 

The easiest thing I can think of would be to set your view as the table's tableFooterView

chrispix
Thanx chrispix.. but footerView doesn't helpme achieve my requirements. Basically, I'm trying to make pullToReload view under my tableview which should be placed below tableview, so that whenever ending content-offset of tableview contentview is visible, this should not be visible, whereas the footerView is visible at the ending offset of tableview contentview.
neha
A: 

I think what you're looking for is self.view.bounds.size.height.

Check out Oliver Drobnik's detailed post on creating a pull-to-reload table view. In his case it's easier, because the view is at the top, so he checks for a negative contentOffset.

If you want it at the bottom, you could check for scrollView.contentOffset.y > (self.view.bounds.size.height + pullToReloadViewHeight)

chrispix
A: 

If you've implemented your own custom cells, then you've probably already implemented this function in your table delegate:

- (CGFloat)tableView:(UITableView *)tableView
           heightForRowAtIndexPath:(NSIndexPath *)indexPath

Just iterate through your rows, calling this function for each one, and sum up the result.

Tim Rupe