大佬教程收集整理的这篇文章主要介绍了ios – 在点击非可选单元格后取消选择先前选择的UICollectionViewCells,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我的一些细胞是可选择的,有些则不是.这是一系列事件:
>我通过点击它们并选择YES来选择几个单元格
> shouldHighlightItemATindexPath:
> shouldSELEctItemATindexPath:
>我尝试通过点击它来选择一个不可选择的单元格(通过将NO返回给shouldSELEctItemATindexPath来实现不可选择的方面:)
>结果:取消选择所有选定的单元格,并在它们上调用didDeSELEctItemATindexPath:.注意:shouldDeSELEctItemATindexPath:未被调用.
预期结果:没有任何反应.
- (BOOL)collectionView:(UICollectionView *)collectionView shouldSELEctItemATindexPath:(NSIndexPath *)indexPath { BOOL isSELEctable = /* decide if currently tapped cell should be SELEctable */; NSIndexPath *SELEctedItemIndexPath = /* NSIndexPath of the current SELEcted cell in the collection view,set in collectionView:didSELEctItemATindexPath: */; if (!isSELEctablE) { // the cell isn't SELEctable,we have to reSELEct the prevIoUsly SELEcted cell that has lost SELEction in the meanwhile // without reloading first the cell the SELEction is not working... [collectionView reloadItemsATindexPaths:@[SELEctedItemIndexPath]]; [collectionView SELEctItemATindexPath:SELEctedItemIndexPath animated:YES scrollPosition:UICollectionViewScrollPositionNone]; } return isSELEctable; }
如果您的集合视图正在滚动(隐藏当前选定的单元格),请记住重新选择collectionView:cellForItemATindexPath:中的单元格.
我不太喜欢这个解决方案,它太“hacky”,但它确实有效.我希望在collectionView中执行所有逻辑:shouldDeSELEctItemATindexPath:但它没有被调用,我不明白为什么.
以上是大佬教程为你收集整理的ios – 在点击非可选单元格后取消选择先前选择的UICollectionViewCells全部内容,希望文章能够帮你解决ios – 在点击非可选单元格后取消选择先前选择的UICollectionViewCells所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。