相关疑难解决方法(0)

UICollectionView shouldSelectItemAtIndexPath = NO不会避免取消选择旧的选择?

我在CollectionView中有多个项目,但只有少数项目可以选择.我正在使用委托方法处理这个:

- (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)

如果选择了可选项,则会出现问题,并且在下一步中,如果shouldSelectItemAtIndexPath返回NO,则拒绝选择不可选项,否则将取消选择所选项.

我也试过用

- (BOOL)collectionView:(UICollectionView *)collectionView shouldHighlightItemAtIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)

但这是同样的问题.

这是UICollectionView正确的期望行为吗?如果是,如果选择了一个不可选择的项目,我怎样才能避免取消选中我上次选择的项目?

selection uicollectionview

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

标签 统计

selection ×1

uicollectionview ×1