ios - 在 UITableView 中, "visibleCells"的代表是什么?

标签 ios uitableview

当单元格进出设备屏幕时,我希望我的 viewController 准确知道什么进来了,什么出去了。有办法做到这一点吗?

最佳答案

没有专门针对“可见单元格”的委托(delegate)方法。当单元格离开屏幕时,不会调用任何东西。当一个单元格变得可见时,实际上什么都没有。

cellForRowAtIndexPath 数据源方法。当需要一个单元格时调用它。

willDisplayRowAtIndexPath 委托(delegate)方法。当一个单元格将被显示时调用。

didEndDisplayingCell 委托(delegate)方法。当从表格 View 中删除单元格时调用此方法。

UITableView 上有 indexPathsForVisibleRows 方法。这让您知道当前查看的是哪些行。

UITableViewCell 上有prepareForReuse 方法。这使单元格可以重置自身以重新用于另一行。

更好地描述您要完成的目标以获得更具体的答案。

关于ios - 在 UITableView 中, "visibleCells"的代表是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34957992/

相关文章:

iOS swift : UIPanGestureRecognizer on 2 differents views

ios - 页脚 View 不会粘在 UITableView 的底部,而是与表格重叠(自动布局问题)

swift - 在 UITableView 中使用 CustomStringConvertible

ios - 日期选择器不会显示在自定义 UITableViewCell 类中

ios - 如何在 UITable 中实现 Instagram 评论的效果?

ios - 使用按钮显示来自 JSON 的文本

ios - 在 Swift 3 中每 1 秒通过 NSTimer 更新自定义 tableviewcell 标签

iOS App 包含开发者路径信息

iOS - 一个 SegmentedControl - 多个 ViewControllers

ios - 在 UISearchDisplayController 中选择单元格后滚动到 UITableView 中选定的单元格?