2017-08-01 55 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,對於使用分組樣式的表格視圖,節標題和頁腳不會浮動