2012-03-22 66 views

回答

42

有一个UITableViewCell高度的委托函数。

在这里您可以指定特定细胞的indexPath,回到你的高度,它

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 
    if(indexPath.section == yourSection && indexPath.row == yourRow) { 
     return 150.0; 
    } 
    // "Else" 
    return someDefaultHeight; 
} 
2
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 

您可以使用此方法为特定索引路径设置单元格的值,并为其他单元格设置默认值。

7

你必须知道,或者找出你想高大的一个什么细胞指数。 可以说它是你的第一个细胞。

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

    if (indexPath.row == 0) { //change 0 to whatever cell index you want taller 
     return 150; 
    } 
    else { 
     return 44; 
    } 
} 
3

SWIFT ANSWER

指定哪些部分和行要更改(记住计数从0开始,而不是1)在heightForRowAtIndexPath方法。

override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat{ 
    if indexPath.section == 0 && indexPath.row == 0{ 
     return 150 
    } 
    return 44.0 
} 
相关问题