UICollectionView中放置imageView各种操作并不会导致什么问题, 但是这个imageView如果是animation的效果, 那么就会诡异的消失, 不知道是否算bug, 这时候需要给imageView和collectionView分别配置
修复方式
imageView 配置
//在uiimageview的内部设置高亮动画内容, 可以设置为默认相同的images地址
[self setHighlightedAnimationImages:images];
collectionView 配置
//没错, 就是在选中, 取消选中, 高亮, 取消高亮下都让cell的动画再开始播放
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
CustomCell * cell = (CustomCell *)[collectionView cellForItemAtIndexPath:indexPath];
if(cell){
[cell.imageView startAnimating];
}
}
-(void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath{
CustomCell * cell = (CustomCell *)[collectionView cellForItemAtIndexPath:indexPath];
if(cell){
[cell.imageView startAnimating];
}
}
-(void)collectionView:(UICollectionView *)collectionView didHighlightItemAtIndexPath:(NSIndexPath *)indexPath{
CustomCell * cell = (CustomCell *)[collectionView cellForItemAtIndexPath:indexPath];
if(cell){
[cell.imageView startAnimating];
}
}
-(void)collectionView:(UICollectionView *)collectionView didUnhighlightItemAtIndexPath:(NSIndexPath *)indexPath{
CustomCell * cell = (CustomCell *)[collectionView cellForItemAtIndexPath:indexPath];
if(cell){
[cell.imageView startAnimating];
}
}
屏蔽方式
可以将collectionView的cell交互禁掉
layerCollection.allowsSelection = false;