UITableView自定义页脚消失

时间:2014-01-30 03:01:51

标签: ios uitableview

我使用了自定义的UITableView页脚,它工作正常,但是当我在heightForRowAtIndexPath中更改单元格高度时,页脚就会消失。

编辑:

我在这里创建页脚

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    actStreamFooter = [[[NSBundle mainBundle]loadNibNamed:@"AcvitityStreamFooter" owner:self options:nil]objectAtIndex:0];
    footerHeight = actStreamFooter.frame.size.height;

    UIButton *taptoLoad = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, actStreamFooter.frame.size.width, actStreamFooter.frame.size.height)];
    [taptoLoad addTarget:self action:@selector(tapToLoad) forControlEvents:UIControlEventTouchUpInside];
    [actStreamFooter addSubview:taptoLoad];

    if (section == 1) {
        return actStreamFooter;
    }
    else{
        return nil;
    }
}

然后我打电话

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

因为我需要更新行,因为我在每个单元格中都有一个展开的视图。

更改高度后页脚消失了我尝试[tableView reloadData]它的工作原理页脚不会消失,但重新加载时会出现故障。我想删除故障

1 个答案:

答案 0 :(得分:0)

需要为每个部分初始化并返回新的页脚。 UIView不能在视图中不止一次。