iOS UIcollectionView多选

    //实现多选必须实现这个方法

    self.collectionView.allowsMultipleSelection = YES;


#pragma mark - 返回这个UICollectionView是否可以被选择

-(BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath

{

    return YES;

}


#pragma mark - 点击事件

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

{

    NSLog(@"点击cell %@",indexPath);

    

    FindFuWuCell * cell = (FindFuWuCell *)[collectionView cellForItemAtIndexPath:indexPath];

    cell.btnLabel.textColor =BaseRedColor;

    

    NSLog(@" id %@ ",cell.data.id);

    

    

}


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

{

    NSLog(@"取消cell %@",indexPath);

    

    FindFuWuCell * cell = (FindFuWuCell *)[collectionView cellForItemAtIndexPath:indexPath];

    cell.btnLabel.textColor =BaseBlackTextColor;

    

}


猜你喜欢

转载自blog.csdn.net/iotjin/article/details/80137427