Ale*_*147 0 ios uicollectionview uicollectionviewcell swift3
如果在索引 path.item 的单元格中满足某些条件,我想访问集合视图中的前一个单元格(索引 path.item - 1)以更改那里的某些设置
现在我试过这个:
let previousCell = collectionView.cellForItem(at: indexPath - 1)
Run Code Online (Sandbox Code Playgroud)
但它不起作用,因为 - 1 它从索引路径向下转换为整数值。
我怎么得到这个细胞?
请检查 :
let previousCell = collectionView.cellForItem(at: IndexPath(row: indexPath.row-1, section: indexPath.section))
Run Code Online (Sandbox Code Playgroud)
获取带有标识符的单元格:
let prevIndexPath = IndexPath(row: indexPath.row-1, section: indexPath.section)
let previousCell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: prevIndexPath)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3003 次 |
| 最近记录: |