gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 18:07:03 24 4
gpt4 key购买 nike

我有大约 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com