2016-04-07 101 views
-1

我想製作一個tableView,其中我想要第一個單元格頁腳和第二個單元格頭將被合併。我試圖將兩者都刪除,但仍然存在分隔線。刪除頁腳和頁眉之間的分隔線IOS

有沒有辦法可以刪除第一個單元格的頁腳和第二個單元格的標題之間的分隔符。

還有一兩件事,我想給高度與頁腳和頁眉 在

- (UIView*) tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { 
    UIView* footerView = nil; 

    switch (section) { 
     case 0: 
      footerView = [[UIView alloc] initWithFrame: CGRectMake(0, 0, tableView.bounds.size.width, 0.01f)]; 
      // footerView.backgroundColor = [UIColor greenColor]; 
      break; 

     case 1: 
     { 
      footerView = [[UIView alloc] initWithFrame: CGRectMake(0, 0, tableView.bounds.size.width, 30)]; 
     } 
      break; 

     case 2: 
     { 
      footerView = [[UIView alloc] initWithFrame: CGRectMake(0, 0, tableView.bounds.size.width, 30)]; 
     } 
      break; 

     default: 
      break; 
    } 

    return footerView; 
} 

但仍然是兩個頁眉和頁腳的高度保持相同 我無法知道是什麼原因?

回答

0

由於行分隔符是UITableView的屬性,所以不能採用默認方式隱藏特定單元格的分隔符。然而,你可以使用帶有底線圖像(這是目前在自定義單元格的容器視圖的底部)自定義單元格,你可以很容易隱藏和顯示像下面

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 
    Your_custom_cell *cell = //initialise your cell 
    if (indexPath.row == 0){ 
    cell.bottom_line_image.hidden = YES; 
    } 
    else 
    { 
    cell.bottom_line_image.hidden =NO; 
    } 

不要忘了設定的tableview的分離器的風格,形象在viewDidLoad中()

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    your_table_istance.separatorStyle = UITableViewCellSeparatorStyleNone; 
} 
+0

您需要實現下面的tableview委託方法返回頁腳高度 - (CGFloat的)的tableView:(UITableView的*)的tableView heightForFooterInSection:(NSInteger的)部分 { CGFloat的footerHieght = 30.0;如果(section == 0) footerHight = 1.0; } return footerHight; } –