---
title: "Getting tap gesture on UICollectionViewCell in iOS."  
description: "Getting tap gesture on UICollectionViewCell in iOS."  
author: "Anonymous User"  
published: 2015-12-24  
updated: 2015-12-25  
canonical: https://www.mindstick.com/forum/33785/getting-tap-gesture-on-uicollectionviewcell-in-ios  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 1 minute  

---

# Getting tap gesture on UICollectionViewCell in iOS.

I am created a [collection view](https://www.mindstick.com/forum/33803/how-to-set-collection-view-cell-size-in-ios) cell to display [multiple](https://www.mindstick.com/blog/12797/iowa-is-expected-to-see-heavy-growth-in-multiple-sectors) images. My [problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic) is how to get tap [gesture](https://yourviews.mindstick.com/view/228/female-passenger-praised-uber-drivers-gesture) on a small icon, which is on top [right](https://www.mindstick.com/articles/12766/check-whether-you-are-doing-digital-transformation-right-or-not) cell image.

I am using this code:

```
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(projectSetting:)];iconButton = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"imageName.png"]]; iconButton.frame = CGRectMake(50, 10, 50, 50); [iconButton addGestureRecognizer:tapped]; [cell addSubview:iconButton];
```

Please [anyone tell me](https://www.mindstick.com/interview/23033/can-anyone-tell-me-about-hadoop-toolbox) what's [wrong](https://answers.mindstick.com/qa/48468/who-wrote-the-the-wrong-enemy-america-in-afghanistan-2001-2014-and-when) in my code?

## Replies

### Reply by Tarun Kumar

To identify the tap on the icon, add tap Gesture Recogniser on the icon:

```
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];[icon addGestureRecognizer:singleTap];
```

after that add handleSingleTap: method-

```
-(void)handleSingleTap:(id)sender{    // do your stuff;}
```


---

Original Source: https://www.mindstick.com/forum/33785/getting-tap-gesture-on-uicollectionviewcell-in-ios

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
