如何在UITableView中添加页脚? [英] How to add a footer to the UITableView?
本文介绍了如何在UITableView中添加页脚?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用此代码向TableView添加页脚。它有20个部分,每个部分有几行。有一个titleForHeaderInSection和sectionForSectionIndexTitle方法。
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方法
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
并为表格的相应部分返回所需的视图(例如,在页脚中包含您想要的文本的UILabel)。 / p>
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];
What am I doing wrong?
thanks,
RL
解决方案
You need to implement the UITableViewDelegate method
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
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屋!
查看全文