---
title: "How to allow multiple selection in UICollectionView in iOS?"  
description: "How to allow multiple selection in UICollectionView in iOS?"  
author: "Anonymous User"  
published: 2015-12-23  
updated: 2015-12-23  
canonical: https://www.mindstick.com/forum/33778/how-to-allow-multiple-selection-in-uicollectionview-in-ios  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 1 minute  

---

# How to allow multiple selection in UICollectionView in iOS?

I am create an [application](https://www.mindstick.com/articles/12824/calculator-application-in-android) like Photo album in iPhone.\
Can any one tell me that how can I [add](https://www.mindstick.com/forum/12983/add-address-in-textbox-when-page-is-load-and-if-i-search-address-in-textbox-show-in-map-by-javascript) [functionality](https://www.mindstick.com/blog/136/using-watermark-functionality-in-textbox-by-jquery) for [multiple](https://www.mindstick.com/blog/12797/iowa-is-expected-to-see-heavy-growth-in-multiple-sectors) [selection](https://www.mindstick.com/blog/60/populate-records-in-second-listbox-according-to-the-selection-in-first-list-box) for specific [section](https://yourviews.mindstick.com/view/297/reservation-for-economically-weaker-section) in UICollectionView?\
I am using this [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii):

```
[self.collectionView setAllowsMultipleSelection:YES];
```

but, the above code will affects all sections.\
[Please suggest](https://answers.mindstick.com/qa/43506/please-suggest-the-bathing-date-at-kumbh) me any solution?

## Replies

### Reply by Tarun Kumar

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];        }    }}
```


---

Original Source: https://www.mindstick.com/forum/33778/how-to-allow-multiple-selection-in-uicollectionview-in-ios

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
