我是 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