- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
比如tableView有100行,heightForRowAtIndexPath:
在第100行显示之前就已经执行了。
为什么?为了计算tableView的contentSize
?
谢谢!
最佳答案
Every time a table view is displayed, it calls tableView:heightForRowAtIndexPath: on the delegate for each of its rows
是的,它在显示单元格之前被调用。如果您考虑一下,如果表格以相反的方式进行,它将创建一个具有标准高度的单元格,将内容放入其中,获取实际高度,然后调整单元格大小/移动单元格。那可不太好。
这可能会导致性能问题,因此您应该只在具有不同高度的单元格时使用它:
The method allows the delegate to specify rows with varying heights. If this method is implemented, the value it returns overrides the value specified for the rowHeight property of UITableView for the given row.
There are performance implications to using
tableView:heightForRowAtIndexPath:
instead of the rowHeight property. Every time a table view is displayed, it callstableView:heightForRowAtIndexPath:
on the delegate for each of its rows, which can result in a significant performance problem with table views having a large number of rows (approximately 1000 or more).
否则,如果所有单元格的高度都相同,请使用 rowHeight
属性,并且不要实现 tableView:heightForRowAtIndexPath:
。
关于iphone - heightForRowAtIndexPath : was executed before cell is show?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12262588/
我需要从 tableView:heightForRowAtIndexPath: 访问表格中的单元格因为我想使用客户单元格中的数据来进行高度计算。我发现获取单元格的唯一方法是调用 tableView:c
我很难理解 UITableViewController 的流程。基本上这是我的结构: 我有一个tableViewController,它当然包含一个tableView。在这里,我使用 getCellC
我正在尝试创建一个包含 3 个组的分组 TableView ,每个组都有不同高度的单元格。我在我的 Storyboard 中设置了 3 个具有适当高度的原型(prototype)单元,并设置了我的 U
我有一个包含200-300个不同高度的单元格的表+一个包含UITextView的单元格(该表用于读取和发送消息)。我需要在键入文本时动态调整单元格(包含UITextView)的高度。我使用下一个代码来
我有大约 30 个 View Controller ,它们都有一个实现“heighForRowAtIndexPath”的通用基类。现在我们最近删除了 iOS 7 支持,这让我们可以使用 AutoLay
我正在尝试在我的 tableView 中显示具有正确宽高比的图像。我已经预先计算了图像的长宽比,它似乎在实际图像上正常工作,但在它显示的单元格上却不起作用。 单元格中图像的代码: private va
我想学习一种通用且正确的自定义单元格高度计算方法。 我的单元格是从 nib 加载的,它们有两个多行 UILabels,一个在另一个之上。 目前,我在 viewDidLoad 中创建特殊配置单元格,并在
heightForRowAtIndexPath 函数有一个奇怪的问题。我需要第 3 行的高度更高,但它总是设置下一行(在本例中为第 4 行)的高度。 我会解释: - (CGFloat)tableVie
我正在我的应用中实现聊天功能,并且我正在滚动自己的 UIViewController 来实现此功能。我使用 UITableView 而不是 UICollectionView,因为它更适合我的需求。 我
我在 iOS 应用程序中遇到线程问题。这是一个已经发展了几年的大型应用程序。 (我是这个项目的许多贡献者之一,并且只对它的某些部分有深刻的理解)。 在某些情况下,应用会进行后台刷新,从而触发 tabl
在我的表格 View 中,表格被加载,图像被加载,当图像被加载时,我想从我配置单元格的 ProductTableViewCell.swift 文件再次调用这个函数。 override func tab
我的应用程序有大约 30 个活跃用户和 500 多个注册用户,这个问题只发生在一个使用 iPhone 6 的 9.2 用户身上。 我从崩溃报告中可以看出她已经发生了 60 多次崩溃,并且她说问题有时是
长话短说,iOS8 在 UITableViewAutomaticDimension 上有一个错误 因此,您不能只调用 tableView.rowHeight = UITableViewAutomati
我有一张包含静态单元格的表格。对于一个单元格,我想根据标签的高度(在该单元格内)更改其高度,同时保持所有其他单元格的高度不变。如何获得当前单元格的高度?或者也许有更好的方法? - (CGFloat)t
我有一个表格 View ,我将所有的奇数单元格高度设置为 0,在奇数单元格中我有一些标签。当它显示表格 View 时,奇数单元格中的标 checkout 现在偶数单元格中。有什么办法可以让标签消失吗?
我需要在表格 View 的单元格中加载 HTML。我使用 UIWebView 而不是 UILabel 以便解释 html 标签。WebView 的大小不同,所以我这样做 - (void)webView
我有一个UITableView (分组!)并且需要计算两种样式单元格的高度:UITableViewCellStyleDefault和UITableViewCellStyleValue2 . 我就是这样
在我的 heightForRowAtIndexPath 方法中,我只想为某些行自定义高度。对于其余的事情,我希望框架能够照顾好。我该怎么做? 最佳答案 您可以只返回tableView.rowHeigh
谁能解释一下 tableView:heightForRowAtIndexPath 方法的生命周期。这个方法在什么时候被调用。 第一次填充 TableView 时的示例。 除此之外,任何时候调用此方法?
我正在尝试在 UITableViewController 中使用 heightForRowAtIndexPath 方法。但是当我尝试重写该方法时,它说它不会重写其父类(super class)中的任何
我是一名优秀的程序员,十分优秀!