简体   繁体   English

滚动时页脚叠加在tableview单元格内容的顶部

[英]Footer overlays on top of tableview cell contents while scrolls

I have added footerview programmatically for each section as follows. footerview编程方式为每个部分添加了footerview ,如下所示。 I could able to see the footerview . 我能够看到footerview

However, when I scroll up or down at the bottom or at the top of the tableview, footerview overlays on top of tableviewcells . 但是,当我向上或向下滚动到tableview的底部或顶部时, footerview覆盖tableviewcells顶部。

How could I able to disable it? 如何禁用它?

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    if(adminOrderElements[section].expanded && [adminOrderElements[section].notes length]>0)
    {
        return 60;
    } else {
        return 0;
    }

    return 60;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *footer = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 60)];
    footer.backgroundColor = [UIColor clearColor];

    UILabel *lbl = [[UILabel alloc]initWithFrame:footer.frame];
    lbl.backgroundColor = [UIColor clearColor];
    lbl.text = @"Your Text";
    lbl.textAlignment = NSTextAlignmentCenter;
    [footer addSubview:lbl];

    return footer;
}

Before Scroll 滚动前

在此处输入图片说明

After Scroll 滚动后

在此处输入图片说明

If I understand your question correctly, you only have to change the UITableViewStyle to UITableViewStyleGrouped . 如果我没有理解你的问题,你只需要改变UITableViewStyleUITableViewStyleGrouped According to the docs , for table views using grouped style the section headers and footers do not float . 根据文档 ,对于使用分组样式表视图,节的页眉和页脚不会浮动

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM