【发布时间】:2018-04-04 06:59:07
【问题描述】:
func loadMoreData(lBound: Int, uBound: Int){
for i in lBound...uBound{
tempArray.append(arrayDealPage[i])
}
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now()+0.25, execute:{
self.dealsTable.reloadData()
})
}
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if arrayDealPage.count != tempArray.count
{
let lastItem = tempArray.count - 1
if indexPath.row == lastItem{
loadMoreData(lBound: tempArray.count, uBound:(tempArray.count-1)+20)
}
}
}
我从图像数组中获取 195 个数据,我想一次只显示 20 个,然后滚动添加另外 20 个。上面的代码工作正常,但是当我达到大约 181 或 182 个单元格时,它会崩溃索引超出范围错误.195数组计数将来可能会增加如何解决索引超出范围错误。有人可以帮助我提前感谢。
【问题讨论】:
标签: arrays uitableview swift3