- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当您有很多单元格时,
heightForRowAtIndexPath
是一项非常昂贵的操作。在我的例子中,我有数千个,所以我想我可以分批分解表格并一次只显示 50 个单元格,并且当用户接近表格 View 边界的末尾时,使用 insertRowsAtIndexPaths:
再插入 50 行。但是,每次我插入 50 个新行时,都会为表的所有行调用 heightForRowAtIndexPath
,而不仅仅是我刚刚插入的行。这是预期的行为吗?为什么是这样?我的行高必须计算带有字体的字符串的高度,因此每次插入新行时计算整个表格的高度是非常低效的。有任何解决方法吗?
最佳答案
Is this expected behavior? Why is this?
是的,这使得将具有不同高度的行插入到一个表中成为可能。
Are there any workarounds?
如果所有行的高度都相等,则在初始化期间只计算一次高度。
每次调用 heightForRowAtIndexPath
时,只需返回缓存的结果。
关于iphone - 为什么调用 insertRowsAtIndexPaths : call heightForRow for all rows?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11171983/
我需要对某些单元格使用 UITableViewAutomaticDimension,还需要对其他一些单元格使用 heightForRow 是否可以在同一个 TableView 中同时使用它们?如果可能
我创建了一个 viewController,它显示一个普通样式的 UITableView。有时我有足够的单元格来填充表格 View ,有时却没有。当我没有足够的单元格时,我想缩小表格 View ,以便
当您有很多单元格时, heightForRowAtIndexPath 是一项非常昂贵的操作。在我的例子中,我有数千个,所以我想我可以分批分解表格并一次只显示 50 个单元格,并且当用户接近表格 Vie
我正在尝试根据内容制作具有动态单元格高度的 UITableView。我的应用程序是一个文章查看器。我尝试使用这些函数计算单元格的高度。 func heightForView(text:String,
我有一个 UITableView,它有几个不同高度的单元格。每一行都根据其包含的内容进行动态调整。 我有一个自定义的 UITableViewCell,里面有一个 UICollectionView,它应
我只是在 UITableViewCell 上寻找 UIWebView 和 UILabel 的动态高度。 This is great example for UIWebView in UITableVi
最近我将我的 Xcode 从 v 5.1.1 更新到 6.0.1。在验证我当前的 Cocos2d v3.1 项目期间,iTunes 商店向我显示警告 iTunes Store operation fa
我是一名优秀的程序员,十分优秀!