如果 viewForHeaderInSection 中的自定义单元格重新加载特定的 viewForHeaderInSection IOS,我想重新加载 viewForHeaderInSection。
我使用了以下代码
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:section] withRowAnimation: UITableViewRowAnimationAutomatic];
但整个部分将重新加载
我也通过创建自定义 View 尝试了以下操作
SearchHeaderView 是自定义 View
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
lblPrice_Header.text = [NSString stringWithFormat:@"%d",cartSum] ;
return SearchHeaderView;
}
-(void)cartSum :(id)sender{
.....
.......
=======================================
cartSum =cartSum+[[subArray objectAtIndex:j] intValue]*price;
UIView *headerVw = [self.tableView headerViewForSection:section];
[headerVw setNeedsDisplay];
[headerVw setNeedsLayout];
}
但它不会重新加载该部分。
我的部分标题如下所示
我已经检查了以下链接
Reloading tableView header in ios7
Changing UITableView's section header/footer title without reloading the whole table view
最佳答案
你可以尝试这样的事情:
UIView *headerVw = [YOURTABLEVIEW headerViewForSection:section];
[headerVw setNeedsDisplay];
[headerVw setNeedsLayout];
注意:
- 要处理特定 View ,您也可以定义标签
希望它对你有用。
关于ios - 对于 viewForHeaderInSection 中的自定义单元格,重新加载特定的 viewForHeaderInSection IOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31692692/