我有一个使用情节提要实现的自定义部分标题视图类。在 viewForHeaderInSection 方法中加载视图时,我可以根据需要设置各种标签和视图。
static NSString *CellIdentifier = @"HeaderCell";
HourlyCustomTableSectionHeader* headerCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
NSString *sectionHeaderTitle = [[NSString alloc] init];
if(section==0){
sectionHeaderTitle = @"TODAY";
headerCell.CustomHeaderTitle.text = sectionHeaderTitle;
}
但是,我想从每次可见新单元格时运行的另一种方法更新其中的一些。
基本上 - 我想设置部分标题的背景颜色以匹配最上面的单元格并随着用户滚动而更新。
我在尝试引用要更新的属性时遇到问题。为简单起见,我首先尝试更新自定义文本标签。
HourlyCustomTableSectionHeader* customSectionHeadObj = [[HourlyCustomTableSectionHeader alloc] init];
customSectionHeadObj.CustomHeaderTitle.text = @"new title";
Xcode 似乎对路径很好(没有显示错误),我可以看到每次更新表视图并且看到一个新单元格时调用该方法很好,但节标题中的标签没有更新。
我会以正确的方式解决这个问题吗?或者我可能需要刷新部分标题以使更新可见?