在不重新加载整个表格视图的情况下更改UITableView的部分页眉/页脚标题 [英] Changing UITableView's section header/footer title without reloading the whole table view

查看:134
本文介绍了在不重新加载整个表格视图的情况下更改UITableView的部分页眉/页脚标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以在不调用
[tableView reloadData];

$ b $的情况下重新加载表视图的节头/页脚b

实际上,我想在其分节页脚的表格视图部分显示单元格的数量。表视图是可编辑的,我使用

   -  insertRowsAtIndexPaths:withRowAnimation:
- deleteRowsAtIndexPaths:withRowAnimation删除或插入行:

看起来这些方法不会更新分节页脚。奇怪的是,当我调用这些方法时,表视图的数据源方法是

   - (NSString *)tableView:(UITableView *)table titleForFooterInSection:(NSInteger)节

被调用(两次!),但它不会更新表视图新的价值!!



任何人有任何想法如何解决这个问题?

解决方案

我创建了一个UILabel并将其设置为节头/页脚。

 <$ c $ (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
// update sectionFooterView.text
return sectionFooterView;

$ b - (void)viewDidLoad {
//在Interface Builder中创建sectionFooterView,在这里更改框架
//使用Font-size:15,BG-颜色:clearColor,text-Color:RGB =(97,105,118)
//和文本对齐:居中看起来像表视图的原始页脚
sectionFooterView.frame = CGRectMake(0,10,320,12) ;





$ b

有没有人知道没有设置自定义页脚视图的方法? / p>

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?

解决方案

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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆