刷新didSelectRowAtIndexPath委托的viewForFooterInSection

Tar*_*riq 5 iphone footer uitableview

我在不同的部分显示UITableViewCell上的项目列表.我在viewForFooterInSection委托中创建了UITextField

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
Run Code Online (Sandbox Code Playgroud)

现在我的问题是我不想每次都显示viewForFooterInSection.它应该是nil/hidden,直到我单击该特定部分的didSelectRowAtIndexPath.并且UITextField应仅显示该部分.

我很困惑如何在点击时重新加载footerView?

Aks*_*hay 7

您只需重新加载该部分即可重新加载页脚视图.

[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationNone];
Run Code Online (Sandbox Code Playgroud)

在此调用之后,- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section再次命中,您可以保留一个布尔变量,并相应地返回nil或您的页脚视图.

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    if(conditionSatisfied)
        return myFooterView;
    return nil;
}
Run Code Online (Sandbox Code Playgroud)

HTH,

阿克沙伊

  • 重新加载部分clobbers你可能一直在做的任何其他动画.我没有看到任何迹象表明存在,但reloadSectionFooter方法将是要走的路. (2认同)