UICollectionView的多选

来源:互联网 发布:ae软件怎么下载 编辑:程序博客网 时间:2024/05/17 09:15

设置cell 是否是选中状态和所有选中的cell的数组

@property(nonatomic,strong)NSMutableArray *totalArr;

@property(nonatomic,assign)BOOL isSelected;

//点击选定

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath

{

    QDCollectionViewCell *cell = (QDCollectionViewCell *)[collectionViewcellForItemAtIndexPath:indexPath];

    

        if ([_totalArrcontainsObject:cell]) {

            cell.SelectedImage.image=[UIImageimageNamed:@""];

            [_totalArrremoveObject:cell];

        }else{

            cell.SelectedImage.image=[UIImageimageNamed:@"选中"];

            [_totalArraddObject:cell];

            

        }

    _isSelected=!_isSelected;

   

    

    

}



原创粉丝点击