iphone - 以编程方式为单个 UITableViewCell 设置高度?

标签 iphone objective-c uitableview

我需要以编程方式为我的 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/

相关文章:

iphone - UIImageView 作为 UITextView 的背景

iphone - 使用 AFNetworking 解析 XML 文件

ios - UITableView 页脚与 iOS 11 中的单元格重叠

iphone - 我应该保存哪些私钥才能重建我的 iOS 应用程序?

ios - 更改itms-services安装提示信息

iphone - AVAudioRecorder 不会在设备上录制

ios - 如何在 UITableViewController 中使用段 Controller 设置导航栏标题?

iphone - 无法更改导航项后退按钮的文本和文本颜色

objective-c - 回到 sel_getUid() 的原始行为

ios - 我们实际上在代码中对属性做什么?