在不重新加载整个表格视图的情况下更改 UITableView 的部分页眉/页脚标题 [英] Changing UITableView's section header/footer title without reloading the whole table view
问题描述
有没有办法在不调用的情况下重新加载表格视图的部分页眉/页脚[tableView reloadData];
?
Is there any way to reload the section header/footer of a table view without calling
[tableView reloadData];
?
事实上,我想在其部分页脚中显示表格视图部分中的单元格数量.表视图是可编辑的,我使用
In fact, I want to show the number of cells in a table view's section in its section footer. The table view is editable and I delete or insert rows using
– insertRowsAtIndexPaths:withRowAnimation:
– deleteRowsAtIndexPaths:withRowAnimation:
似乎这些方法不会更新节页脚.奇怪的是,当我调用这些方法时,表视图数据源方法
It seems that these methods do not update the section footer. Strangely, when I call these methods the table view data-source method
- (NSString *)tableView:(UITableView *)table titleForFooterInSection:(NSInteger)section
被调用(两次!)但它不会用新值更新表视图!!
is called (twice!) but it does not update the table view with the new values!!
有人知道如何解决这个问题吗?
Anyone has any idea how to fix this problem?
推荐答案
我设法以一种间接的方式做到了:我创建了一个 UILabel 并将其设置为节页眉/页脚.
I managed to do it in an indirect way: I created a UILabel and set it as section header/footer.
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
// update sectionFooterView.text
return sectionFooterView;
}
- (void)viewDidLoad {
// create sectionFooterView in Interface Builder, change the frame here
// use Font-size:15 , BG-Color: clearColor , text-Color: RGB=(97,105,118)
// and Text-alignment:Center to look like table view's original footer
sectionFooterView.frame = CGRectMake(0, 10, 320, 12);
}
有谁知道不设置自定义页脚视图的方法吗?
Does anyone know a way to do this without setting a custom footer view?
这篇关于在不重新加载整个表格视图的情况下更改 UITableView 的部分页眉/页脚标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!