3

我通过属性为 tableView 设置了一个自定义页脚:

self.tableView.tableFooterView = [self myCustomFooterView];

tableView 几乎填满了屏幕的全高,因此底部只有 1/3 的页脚可见。我已禁用弹跳,并且无法将 tableView 滚动到底部以查看 footerView。如果启用了弹跳,那么我可以弹跳并查看表格页脚,但表格在弹跳后会返回到相同的位置。看起来 tableView 内容大小不包括我的 footerView,这就是我无法滚动的原因。任何想法如何解决这个问题?

4

3 回答 3

2

JoshHinman 是对的(“检查表格视图的框架并确保它不大于屏幕。”)。我通过将 MyViewController.view 添加到 AnotherViewController.view 作为子视图来重用 MyViewController 中包含 tableView 的 AnotherViewController。因为 AnotherViewController.view 包含一些 logo 图像,所以 MyViewController.view.tableView 被推到底部。正如他指出的那样,问题是我把 tableView 推得太多了:)

于 2013-07-25T19:23:55.567 回答
0

您必须使用此数据源方法将页脚设置为

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section

还要确保 tableview 的框架可以满足页脚在视图中可见

编辑此方法有助于为每个部分设置页脚,因此如果您想在检查方法中返回的部分后将页脚设置为最后一个部分。

以及提问者的意图这对我有用

UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 40)];
[view1 setBackgroundColor:[UIColor redColor]];

[self.view addSubview:view1];
[self.table setTableFooterView:view1];

所以检查[self myCustomFooterView];

于 2013-07-25T06:53:50.047 回答
0

在设置页脚后,还要编写以下代码UITableView

CGSize wholesize =  self.tableView.contentSize;    
wholesize.height = self.tableView.contentSize.height + self.tableView.tableFooterView.frame.size.height;  

self.tableView.contentSize = wholesize;
[tableView setContentOffset:CGPointMake(0, tableView.contentSize.height) animated:YES];
self.tableView.tableFooterView.userInteractionEnabled = YES;
于 2013-07-25T07:08:07.857 回答