加载时集合视图不是从索引0开始

时间:2018-09-04 16:31:15

标签: ios swift uitableview

我有一个collectionview用作图像库,它的单元格填充了所有大小,并且其中每行只有一个imageview。 我按如下方式加载其数据源:

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ImageSliderCell", for: indexPath) as! SliderCell

    // Configure the cell
    let url = URL(string: ad.images![indexPath.row].small_url!)
    cell.image.kf.setImage(with: url)

    return cell
}

问题是:有时候,当collectionview完成加载时,它会开始在数组中显示第一张照片(因为它应该工作),但是有时它是从不同的索引开始的,例如从第三张照片开始,就像我使用某些东西一样像collectionview.scrolltoindex(3)。

0 个答案:

没有答案