【发布时间】:2016-04-14 16:16:46
【问题描述】:
我正在调用此方法,并且 nextCellIndexPath 是大于当前单元格的 indexPath,但 indexPath 没有正确递增。
这里是 cellForItemAtIndexPath:
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("collectionViewCell", forIndexPath: indexPath) as! ImageCollectionViewCell
cell.nextCellIndexPath = indexPath.indexPathByAddingIndex(1)
return cell
}
当我尝试滚动到下一个 indexPath 时,indexPath 似乎没有增加。
那么如何正确获取下一个 indexPath?
【问题讨论】:
-
看起来您将
nextCell分配为NSIndexPath实例,而不是单元格,对吗? -
正确。我可能应该重命名它。
-
调用滚动时该项目是否已经在屏幕上可见?我认为它只会在项目不完全可见时滚动。
标签: ios swift uicollectionview nsindexpath