ios - 基类实现tableView时如何使用UITableViewAutomaticDimension :heightForRowAtIndexPath:

标签 ios objective-c uitableview ios-autolayout uitableviewautomaticdimension

我有大约 30 个 View Controller ,它们都有一个实现“heighForRowAtIndexPath”的通用基类。现在我们最近删除了 iOS 7 支持,这让我们可以使用 AutoLayout 进行漂亮的自动高度计算。我刚刚看到一个相当复杂的单元格,它非常适合这个自动高度。

文档说明了这一点:

You may set the row height for cells if the delegate doesn’t implement the tableView:heightForRowAtIndexPath: method. The default value of rowHeight is UITableViewAutomaticDimension.



所以似乎因为我的基类实现了 heightFor.. 自动没有生效。

有没有办法解决?我会以某种方式需要“实现”该特定方法。

最佳答案

您可以返回UITableViewAutomaticDimension来自 heightForRowAtIndexPath在您的子类中:

-(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return UITableViewAutomaticDimension;
}

关于ios - 基类实现tableView时如何使用UITableViewAutomaticDimension :heightForRowAtIndexPath:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40130368/

相关文章:

iphone - 无法重置资源语句或进入无限循环

ios - 每当一个物体的y坐标等于另一个物体的y坐标时,如何将分数加1

ios - 将自定义文本添加到 iPhone sdk 中的 uibutton

ios - 冗余图像加载到 tableview 单元格 swift

ios - 只能点击 UITableView 中的一项

ios - 如何在 swift 中重用 uitableviewCell 和自动布局?

ios - 如果我正在执行 CGImageRelease(sourceImageRef), Objective-C ,应用程序崩溃

javascript - 如何使用 Objective C 在 HighChart 上加载 Plist 数据?

ios - 发送 NSMutableURLRequest 时如何在 objective-c 中使用代理服务器?

ios - 如何在 Apple 的 UITableView 样式中获取 subview 的框架位置?