2017-08-01 36 views
0

我已经按编程方式为每个部分添加了footerview,如下所示。我能够看到footerview页脚覆盖在tableview单元格内容的顶部,同时滚动

但是,当我在桌面底部或顶部向上或向下滚动时,footerview叠加在tableviewcells之上。

我怎么能够禁用它?

- (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; 
} 

滚动之前

enter image description here

后滚动

enter image description here

+0

你的'heightForFooterInSection'返回的高度是多少? 60还是0? – Paulw11

+0

如果有'footerview',它是'60'。如果不是,那么它是'0'基于'if(adminOrderElements [section] .expanded && [adminOrderElements [section] .notes length]> 0)' – hotspring

+1

我会建议在你正在返回的零件上添加一个断点0并检查它是否去那里,我认为你不需要第二次返回60声明 – 3stud1ant3

回答

0

如果我正确理解你的问题,你只需要改变UITableViewStyle到。根据the docs,对于使用分组样式的表格视图,节标题和页脚不会浮动

相关问题