iOS 8自动单元格高度 - 无法滚动到最后一行 [英] iOS 8 Auto cell height - Can't scroll to last row

查看:149
本文介绍了iOS 8自动单元格高度 - 无法滚动到最后一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iOS 8新的自动调整单元格。视觉效果很好 - 每个单元都有合适的尺寸。但是,如果我尝试滚动到最后一行,则表格视图似乎不知道其正确的大小。这是一个错误还是有修复?

I am using iOS 8 new self-sizing cells. Visually it works good - each cell gets its right size. However, if I try to scroll to the last row, the table view doesn't seem to know its right size. Is this a bug or is there a fix for that?

使用这个项目 - TableViewCellWithAutoLayoutiOS8 (引自这个SO答案),我按预期得到了自动调整大小的单元格。

Using this project - TableViewCellWithAutoLayoutiOS8 (referenced from this SO answer), I got the auto-resizing cells as expected.

但是,如果我正在调用 scrollToRowAtIndexPath 函数,如下所示:

However, if I am calling the scrollToRowAtIndexPath function, like this:

tableView.scrollToRowAtIndexPath(NSIndexPath(forRow: model.dataArray.count - 1, inSection: 0), atScrollPosition: .Bottom, animated: true)

没有到达最后一行 - 它只让我到了中途。

I do not get to the last row - It only gets me around halfway there.

即使尝试使用这样的较低级别的功能:

Even by trying to use a lower level function like this:

tableView.setContentOffset(CGPointMake(0, tableView.contentSize.height - tableView.frame.size.height), animated: true)

结果不符合预期,它不会结束。如果我点击很多次或等待片刻,最终它会到达正确的位置。似乎tableView.contentSize.height设置不正确,因此iOS不知道最后一个单元格在哪里。

The result is not as expected, it won't get to the end. If I click it a lot of times or wait a few moments, eventually it will get to the right place. It seems the tableView.contentSize.height is not set correctly, so the iOS "doesn't know" where that last cell is.

非常感谢任何帮助。

谢谢

推荐答案

更新:2015年6月24日

Apple已经解决了iOS 9.0 SDK中的大部分漏洞问题。从iOS 9 beta 2开始,所有这些问题都得到了解决,包括滚动到顶部&表视图的底部没有动画,并在表视图中间滚动时调用 reloadData

Apple has addressed most of these bugs as of the iOS 9.0 SDK. All of the issues are fixed as of iOS 9 beta 2, including scrolling to the top & bottom of the table view without animation, and calling reloadData while scrolled in the middle of the table view.

以下是尚未解决的剩余问题:

Here are the remaining issues that have not been fixed yet:


  1. 使用较大的估计行高,使用动画滚动到最后一行会导致表格视图单元格消失。

  2. 使用较小的估计行高时,使用动画滚动到最后一行会导致表视图过早地完成滚动,在可见区域下面留下一些单元格(最后一行仍在屏幕外)。

一个新bug报告(rdar:// 21539211)已针对与动画滚动相关的这些问题提交。

A new bug report (rdar://21539211) has been filed for these issues relating to scrolling with animation.

原始答案

这是一个带有表视图行高估计的Apple bug,它已经存在,因为这个功能首先在iOS 7中引入。我直接与Apple UIKit工程师和开发人员福音传教士就此问题进行了合作 - 他们已经承认这是一个错误,但没有任何可靠的解决方法(没有禁用行高度估计),似乎并没有特别感兴趣修复它。

This is an Apple bug with the table view row height estimation, and it has existed since this functionality first was introduced in iOS 7. I have worked directly with Apple UIKit engineers and developer evangelists on this issue -- they have acknowledged that it is a bug, but do not have any reliable workaround (short of disabling row height estimation), and did not seem particularly interested in fixing it.

请注意,该bug以其他方式表现出来,例如当您调用<$时消失的表视图单元格c $ c> reloadData 在部分或完全向下滚动时(例如 contentOffset.y 显着大于0)。

Note that the bug manifests itself in other ways, such as disappearing table view cells when you call reloadData while scrolled partially or fully down (e.g. contentOffset.y is significantly greater than 0).

显然,使用iOS 8自定义单元格,行高估计非常重要,所以Apple真的需要尽快解决这个问题。

Clearly, with iOS 8 self sizing cells, row height estimation is critically important, so Apple really needs to address this ASAP.

我在2013年10月21日以Radar#15283329的身份提交了这个问题。 请提交重复的错误报告,以便Apple优先处理修复。

I filed this issue back on Oct 21 2013 as Radar #15283329. Please do file duplicate bug reports so that Apple prioritizes a fix.

您可以附加这个简单的示例项目以演示该问题。它直接基于Apple自己的示例代码。

You can attach this simple sample project to demonstrate the issue. It is based directly on Apple's own sample code.

这篇关于iOS 8自动单元格高度 - 无法滚动到最后一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆