【发布时间】:2015-06-24 12:09:04
【问题描述】:
我正在尝试构建一个自定义 UITableView,其行为方式与提醒应用类似。
我希望它被下一个单元格覆盖,而不是最上面的可见单元格从显示屏上滚动出来,这样当您滚动时,这些单元格看起来会相互堆叠。
目前我正在使用:
override func scrollViewDidScroll(scrollView: UIScrollView) {
let topIndexPath: NSIndexPath = tableView.indexPathsForVisibleRows()?.first as! NSIndexPath
let topCell = tableView.cellForRowAtIndexPath(topIndexPath)
let frame = topCell!.frame
topCell!.frame = CGRectMake(frame.origin.x, scrollView.contentOffset.y, frame.size.width, frame.size.height)
}
但顶部单元格始终位于第二个单元格上方 - 导致第二个单元格在其下方滚动。
此外,如果我快速滚动,这似乎会放错我所有的单元格。
编辑:已修复此问题。答案贴在下面以供将来参考。
【问题讨论】:
标签: ios swift uitableview cocoa-touch