我实现了启用了多个选择的UICollectionView。
我的某些单元格是可选的,有些不是。这是事件链:
YES
返回到shouldHighlightItemAtIndexPath:
shouldSelectItemAtIndexPath:
NO
返回到shouldSelectItemAtIndexPath:
来实现的)didDeselectItemAtIndexPath:
。注意:不会调用shouldDeselectItemAtIndexPath:
。 预期结果:无任何 react 。
这是正常行为吗?我在文档中找不到任何内容。如果是这样,我该如何不取消选择单元格呢?
最佳答案
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeue...
cell.userInteractionEnabled = isSelectableIndexPath(indexPath)
return cell
}
func isSelectableIndexPath(indexPath: NSIndexPath) -> Bool {
//logic to check if cell is selectable
}
这通过禁用与单元的交互来起作用。