小编Muj*_*aba的帖子

如何在swift中获取集合视图的当前索引路径

我是 swift 的新手,我面临着获取当前indexpath集合视图的问题,我的代码是这样的

func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
    for cell in SliderCollectionView.visibleCells {
        let indexPath = SliderCollectionView.indexPath(for: cell)
        print(indexPath)
    }
}
Run Code Online (Sandbox Code Playgroud)

我得到了indexPath,但像这样Optional([0, 2])但我需要它作为2

ios uicollectionview swift

2
推荐指数
1
解决办法
6658
查看次数

标签 统计

ios ×1

swift ×1

uicollectionview ×1