2012-05-24 96 views
1

我已經做了表兩種使用界面生成自定義單元格:如何在分組樣式表中設置單元格高度?

enter image description here

一切工作正常,但較低的細胞的高度相同,因爲它上面的細胞。它具有我放置的所有東西 - UIImageView等...

所以我在想,如果不能在表格樣式分組時更改單元格高度?

回答

3
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ 

    if (indexPath.row == 1) { 

    return 100; 
    } 

    return 44; 
} 
+0

不錯,乾淨。如果我能幫上忙,我會盡量避免。 –

2

我們可以使用的UITableView委託方法:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if (indexPath.row == 1) 
     { 
      return 60; 
     } 
    else 
     { 
      return 44; 
     } 
}  
+0

他的第二個單元格需要特定的高度,所以它的indexPath.row == 1 ;-),「else」不是必須的,因爲如果indexPath.row == 1爲true,那麼無論如何你都會返回。 – Retterdesdialogs

2

你必須使用這個

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 

{ 回報75.0f;

}

這是使用完整的我。

相關問題