Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在同样的情况下,iOS9 是 Good,但在 iOS10 中无法获取 cell 的 indexPath。
self.tableView.indexPathForCell(cell): nil
nil
现在,我发现该单元格不在 iOS10 中的 visibleCells 中。这就是问题所在。
在 iOS10 中,cellForRowAtIndexPath是早期调用的。所以,然后,indexPathForCell是nil,因为单元格不可见。
cellForRowAtIndexPath
indexPathForCell
我找到的解决方案是这样的。
if #available(iOS 10, *) { indexPath = self.tableView?.indexPathForRowAtPoint(cell.center) }