iOS UIcollectionView multiple selection

    //To implement multiple selection, this method must be implemented

    self.collectionView.allowsMultipleSelection = YES;


#pragma mark - Returns whether this UICollectionView can be selected

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

{

    return YES;

}


#pragma mark - click event

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

{

    NSLog ( @"Click 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;

    

}


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325406046&siteId=291194637