tableFooterView 属性不修复表视图底部的页脚 [英] tableFooterView property doesn't fix the footer at the bottom of the table view
问题描述
我正在 viewDidLoad 方法中设置页脚视图:
I am setting a footer view in the viewDidLoad method:
UIView *fView = [[UIView alloc] initWithFrame:CGRectMake(0, 718, 239, 50)];
fView.backgroundColor =[UIColor yellowColor];
self.table.tableFooterView = fView;
不幸的是,footer 没有在上面指定的 (x,y)
中绘制,而是粘在单元格上,所以如果 table view 有 4 个单元格,footer 将被绘制在第 5 个单元格.
Unfortunately, the footer is not drawing in the specified (x,y)
specified above, but it stick with the cells, so if the table view has 4 cells, the footer will be drawn in the 5th cell.
我什至尝试了协议方法,tableView:viewForFooterInSection
I even tried the protocol method, tableView:viewForFooterInSection
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
UIView *fView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 239, 50)];
fView.backgroundColor =[UIColor yellowColor];
return fView;
}
问题没有解决,我确定 tableFooterView
属性应该在表格视图底部填充页脚视图,但我不确定我在这里可能遗漏了什么?提前谢谢.
the problem is not resolved, I am sure tableFooterView
property should fi the footer view at the bottom of the table view but I am not sure what I may be missing here? Thanx in advance.
推荐答案
既然你的目标是让页脚固定在屏幕底部,而不是随表格滚动,那么你就不能使用表格查看页脚.事实上,你甚至不能使用 UITableViewController
.
Since your goal is to have a footer that stays fixed at the bottom of the screen, and not scroll with the table, then you can't use a table view footer. In fact, you can't even use a UITableViewController
.
您必须将视图控制器实现为 UIViewController
.然后将自己的表视图添加为子视图.您还将页脚添加为视图控制器视图的子视图,而不是表视图.确保调整表格视图的大小,使其底部位于页脚视图的顶部.
You must implement your view controller as a UIViewController
. Then you add your own table view as a subview. You also add your footer as a subview of the view controller's view, not the table view. Make sure you size the table view so its bottom is at the top of the footer view.
您需要使您的视图控制器符合 UITableViewDataSource
和 UITableViewDelegate
协议,并将所有内容连接起来以复制 UITableViewController
的功能.
You will need to make your view controller conform to the UITableViewDataSource
and UITableViewDelegate
protocols and hook everything up to replicate the functionality of UITableViewController
.
这篇关于tableFooterView 属性不修复表视图底部的页脚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!