Reputation: 60919
I am using the EGOTableViewHeader class provided from:
http://www.drobnik.com/touch/2009/12/how-to-make-a-pull-to-reload-tableview-just-like-tweetie-2/
I am able to display my view at the top of my UITableView:
refreshHeaderView = [[EGORefreshTableHeaderView alloc] initWithFrame:CGRectMake(0.0f, 0.0f - self.tableView.bounds.size.height, 320.0f, self.tableView.bounds.size.height)];
refreshHeaderView.backgroundColor = [UIColor colorWithRed:226.0/255.0 green:231.0/255.0 blue:237.0/255.0 alpha:1.0];
[self.tableView addSubview:refreshHeaderView];
How can I figure out the Y-Coordinate to show this view at the bottom of the last cell in my UITableView?
Upvotes: 0
Views: 2800
Reputation: 175
Can you be a bit more specific? Are there more cells that scroll into place? I'm guessing your tableview has more cells than the screen real-estate provides, so do you want your view to come into place as the last cell is scrolled upward?
Edit: Personally, the idea of figuring out content height on a table view is too messy, especially since you have to add the subview yourself, rather than have the UITableView manage it for you. There is a more elegant solution that works in my opinion:
Create an extra section (that doesn't have to have any rows associated with it). Then implement the function
tableView:viewForHeaderInSection:
Return the view you were meaning to add as a subview under your main table. That should do the trick.
Upvotes: 1
Reputation: 1434
You can get the position of the very bottom of a tableView
by using self.tableView.contentSize.height
.
So your code becomes
refreshHeaderView = [[EGORefreshTableHeaderView alloc] initWithFrame:CGRectMake(0.0f, self.tableView.contentSize.height, 320.0f, self.tableView.bounds.size.height)];
Once you have the position just add the view to your tableView as you did with the previous one.
Upvotes: 1