2011-06-25 118 views
1

我使用变量高度为我的UITableViewCells。这通常正常工作 我发现无论最后一个单元格的高度如何,它都会成为它下面所有空白单元格的高度。如何设置默认的UITableViewCell高度?

有没有一种方法来设置出现在最后一个单元格下方的空白单元格的默认高度?

谢谢。

+0

参见[这个问题](http://stackoverflow.com/questions/1022637/modify-appearance-of-empty-cells-is-plain-uitableview),它可能会有所帮助。不要错过对接受答案的评论。 – albertamg

回答

1

如果您正在使用switch语句,那么在缺省情况下为switch参数设置空单元的默认高度。像这样

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 
    int rowHeight = 40; 
    switch (indexPath.row) { 
     case 0: 
      rowHeight = 80; 
      break; 
     case 1: 
      rowHeight = 300; 
      break; 
     default: 
      rowHeight = <your default value>; 
      break; 
    } 

    return rowHeight; 
} 
相关问题