2012-05-24 101 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;

}

这是使用完整的我。

相关问题