I am using the EGOTableViewHeader class provided from:
我正在使用提供的EGOTableViewHeader类:
http://www.drobnik.com/touch/2009/12/how-to-make-a-pull-to-reload-tableview-just-like-tweetie-2/
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:
我可以在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?
如何找出Y-Coordinate在我的UITableView的最后一个单元格的底部显示这个视图?
2 个解决方案
#1
1
You can get the position of the very bottom of a tableView
by using self.tableView.contentSize.height
.
您可以使用self.tableView.contentSize.height获取tableView最底部的位置。
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.
所以你的代码变成了refreshHeaderView = [[EGORefreshTableHeaderView alloc] initWithFrame:CGRectMake(0.0f,self.tableView.contentSize.height,320.0f,self.tableView.bounds.size.height)];获得该位置后,只需将视图添加到tableView,就像使用上一个视图一样。
#2
1
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?
你能更具体一点吗?是否有更多的细胞滚动到位?我猜你的tableview有比屏幕不动产更多的单元格,所以你希望你的视图在最后一个单元格向上滚动时到位吗?
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:
编辑:就个人而言,在表格视图中计算内容高度的想法太乱了,特别是因为您必须自己添加子视图,而不是让UITableView为您管理它。在我看来,有一个更优雅的解决方案:
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.
返回您要在主表下添加为子视图的视图。这应该够了吧。
#1
1
You can get the position of the very bottom of a tableView
by using self.tableView.contentSize.height
.
您可以使用self.tableView.contentSize.height获取tableView最底部的位置。
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.
所以你的代码变成了refreshHeaderView = [[EGORefreshTableHeaderView alloc] initWithFrame:CGRectMake(0.0f,self.tableView.contentSize.height,320.0f,self.tableView.bounds.size.height)];获得该位置后,只需将视图添加到tableView,就像使用上一个视图一样。
#2
1
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?
你能更具体一点吗?是否有更多的细胞滚动到位?我猜你的tableview有比屏幕不动产更多的单元格,所以你希望你的视图在最后一个单元格向上滚动时到位吗?
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:
编辑:就个人而言,在表格视图中计算内容高度的想法太乱了,特别是因为您必须自己添加子视图,而不是让UITableView为您管理它。在我看来,有一个更优雅的解决方案:
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.
返回您要在主表下添加为子视图的视图。这应该够了吧。