我需要以编程方式为我的 UITableView 中的单个 UITableViewCell 设置高度。我该怎么做?
我需要这个单元格的高度为 150 像素,而所有其他单元格的高度可以保持为默认的 44 像素。
谢谢。
最佳答案
有一个 UITableViewCell 高度的委托(delegate)函数。
在这里您指定该特定单元格的 indexPath 并返回您的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if(indexPath.section == yourSection && indexPath.row == yourRow) {
return 150.0;
}
// "Else"
return someDefaultHeight;
}
关于iphone - 以编程方式为单个 UITableViewCell 设置高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9823921/