【问题标题】:UITableView Custom Footer DisappearsUITableView 自定义页脚消失
【发布时间】:2014-02-22 04:42:03
【问题描述】:

我使用了自定义 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] 它可以工作,页脚不会消失,但是在重新加载时它会闪烁。我想消除故障

【问题讨论】:

  • 你到底在哪里设置页脚?
  • 我编辑了问题。
  • 你是直接通过代码调用heightForRowAtIndexPath吗?
  • 旁注 - 将大部分代码移到 if 语句中。如果您只需要在一个部分中运行所有这些代码,为什么要为每个部分运行所有这些代码?

标签: ios uitableview


【解决方案1】:

需要为每个部分初始化并返回一个新的页脚。 UIView 不能多次出现在视图层次结构中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-12-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多