How to allow multiple selection in UICollectionView in iOS?

Total Post:10

 4463  View(s)
Rate this:

I am create an application like Photo album in iPhone.
Can any one tell me that how can I add functionality for multiple selection for specific section in UICollectionView?
I am using this code:

[self.collectionView setAllowsMultipleSelection:YES];

but, the above code will affects all sections.
Please suggest me any solution?

  1. Post:214

    Re: How to allow multiple selection in UICollectionView in iOS?

    The code I am providing here it will allow multiple selection only at section 1 and will allow only one cell selected at any other section:
    For Example:

    - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
        if(indexPath.section == 1) return;
        NSArray<NSIndexPath*>* indexNo = collectionView.indexPathsForSelectedItems;
        for (int i = 0; i<indexNo.count; i++) {
            NSIndexPath* currentIndex = indexNo[i];
            if(![currentIndex isEqual:indexPath] && currentIndex.section != 1) {
                [collectionView deselectItemAtIndexPath:currentIndex animated:YES];



Enter your email address here always to be updated. We promise not to spam!