2016-05-13 142 views
1

我在TableView中使用了兩個不同的部分,同時first section cell is dynamicsecond section cell is static。在這裏我需要兩個單元格都混合在一個沒有標題標題的部分中。在單個分組表格視圖中添加兩個不同的單元格

enter image description here

上面的圖片我需要靜態小區添加到所述,第一部分 - >所述第一小區的底部,以及第一單元是動態地增加行數,這裏是我的代碼

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
return 2; 

}

和行

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 

int count; 
     switch (section) { 
      case 0: 
       count = [nameArray count]; 
       break; 
      case 1: 
       NSLog(@"section called");  // This line is logged 
       count = 1; 
       break; 
      default: 
       count = 0; 
       break; 
     } 
     return count; 

} 

但我需要這樣的數量,

enter image description here

我想沒有第二節頭,靜態細胞添加到第section.Can你請告訴我如何解決這個問題,謝謝。

+0

G.P.Reddy處理動態高度和頭部的觀點:哥們什麼問題????你想顯示第二節的標題?返回ViewForHeaderInSection中第二節標題的視圖,您將看到它。我不知道你的問題 –

+0

你爲什麼要把靜態和動態單元放到兩個單獨的部分?你爲什麼不把它們放在一個部分,並設置該部分的標題? – MudOnTire

+0

我想靜態單元格添加到第一部分,在第一部分>第一個單元格是動態計數@SandeepBhandari –

回答

0

//你可以使用的tableview的以下委託方法

- (CGFloat)tableView:(HBTableView *)tableView heightForHeaderInSection:(NSInteger)section 
{ 
switch (section) { 
     case 0: 
      return 60; 
     case 1: 
      return 40; 
     default: 
      return 0; 
      break; 
    } 

} 



- (UIView *)tableView:(HBTableView *)tableView viewForHeaderInSection:(NSInteger)section 
{ 

switch (section) { 
     case 0: 
      return view1 
     case 1: 
      return view2 
     default: 
      return view3 
      break; 
    } 
} 
相關問題