我在不同的部分显示UITableViewCell上的项目列表。我在viewForFooterInSection委托中创建了UITextField
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
现在我的问题是我不想每次都显示viewForFooterInSection。它应该是nil / hidden,直到我单击该特定部分的didSelectRowAtIndexPath。并且UITextField应仅显示该部分。
我很困惑如何在点击时重新加载footerView?
答案 0 :(得分:7)
您只需重新加载该部分即可重新加载页脚视图。
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationNone];
在此调用之后,- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
再次点击,您可以保留一个布尔变量,并相应地返回nil或您的页脚视图。
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
if(conditionSatisfied)
return myFooterView;
return nil;
}
HTH,
阿克沙伊
答案 1 :(得分:1)
最简单的答案就是致电[tableView reloadData]
。虽然这不提供任何类型的动画,但在这种情况下,我想不出任何名义上简单的方式来支持动画。可能可以通过在看起来像页脚的部分底部插入一行,但这可能会带来另一大堆我不想处理的问题。
修改:刚刚找到了一个可能稍微好一点的选项:
[tableView reloadSections:withRowAnimation:]
。我不知道这是否会为页脚设置动画,或者它是否会向您的数据提供者发出查询,但它值得一试。