【发布时间】:2016-10-15 12:46:39
【问题描述】:
我的表格视图包含 20 个单元格。屏幕只放置了8个单元格,所以这个函数
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
调用 8 次,我只填充前 8 个单元格。
这个方法也调用了8次:
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if (indexPath.row == 11)
{
tableView.scrollToRow(at: indexPath, at: .top, animated: true)
}
}
我还没有 indexPath.row == 11。 如何滚动到第 11 个单元格?
【问题讨论】:
-
你用的是swift 3.0吗?
-
给我看你的全部代码。
标签: ios swift uitableview scroll