如何向 UITableView 添加页脚? [英] How to add a footer to the UITableView?
本文介绍了如何向 UITableView 添加页脚?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用此代码向 TableView 添加页脚.它有 20 个部分,每个部分有几行.有一个 titleForHeaderInSection 和 sectionForSectionIndexTitle 方法.
I'me using this code to add a footer to the TableView. It has 20 sections, and each section a few rows. There's a titleForHeaderInSection, and sectionForSectionIndexTitle methods.
CGRect footerRect = CGRectMake(0, 0, 320, 40);
UILabel *tableFooter = [[UILabel alloc] initWithFrame:footerRect];
tableFooter.textColor = [UIColor blueColor];
tableFooter.backgroundColor = [self.theTable backgroundColor];
tableFooter.opaque = YES;
tableFooter.font = [UIFont boldSystemFontOfSize:15];
tableFooter.text = @"test";
self.theTable.tableFooterView = tableFooter;
[tableFooter release];
我做错了什么?
谢谢,
RL
推荐答案
需要实现UITableViewDelegate方法
You need to implement the UITableViewDelegate method
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
并为表格的相应部分返回所需的视图(例如,在页脚中带有您想要的文本的 UILabel).
and return the desired view (e.g. a UILabel with the text you'd like in the footer) for the appropriate section of the table.
这篇关于如何向 UITableView 添加页脚?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文