Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9045299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:15:31+00:00 2026-06-16T11:15:31+00:00

I have a UICollectionView displaying image thumbnails. Each Image View in the grid has

  • 0

I have a UICollectionView displaying image thumbnails. Each Image View in the grid has a Tap Gesture. My question is, how can I grab the exact cell that was tapped? E.g. “Tapped on index # 43”.

Additional Comments

  • Tap gesture was created programmatically, did not use the story board.
  • I have ARC and Story Board enabled in this project.

Here’s the closest I’ve come:

UICollectionViewController

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
                 cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    int row = [indexPath row];

    CollectionViewCell *Cell = [collectionView
        dequeueReusableCellWithReuseIdentifier:@"Cell"
                                  forIndexPath:indexPath];
    // Enable tap gesture on each ImageView
    [Cell.ImageView setUserInteractionEnabled:YES];
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture)];
    [tapGesture setNumberOfTouchesRequired:1];
    [tapGesture setNumberOfTapsRequired:1];
    [tapGesture setDelegate:self];
    [Cell.ImageView addGestureRecognizer:tapGesture];

    Cell.ImageView.tag = row; // This tags correctly
}


- (void)tapShowImage // Also, for some reason, 
                     // - (void)handleTapGesture:(UITapGestureRecognizer *)sender
                     // doesn't work. I get an invalid selector error.
{
    NSLog(@"%i", Cell.ImageView.tag);
    // Doesn't work because I can't call Cell.ImageView.tag here.
    // Might be because I"m using SDWebImage to load the image
    // into the ImageView above but not sure.
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T11:15:33+00:00Added an answer on June 16, 2026 at 11:15 am

    You don’t need to add a tap recognizer to each of your cells. You can get the indexPath of the tapped cell in the collectionView:didSelectItemAtIndexPath: method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view set up with two UICollectionViews. Each of these views has
I have a UICollectionView with a series of thumbnails. When I tap on a
I'm using UICollectionView to show grid based View in iPad. I have only 200
I have defined in my Storyboard (iPad) a view that contains a UICollectionView ,
I have a UICollectionView that has only a few cells (about 20). Performance for
I have a quick question, related to if these images of apps, uses UICollectionView
I have a UICollectionView. It scrolls horizontally, has only a single row of items,
In my ViewController I have four subviews, i.e UITableView, UICollectionView, View with UILabels, and
Have deployed numerous report parts which reference the same view however one of them
have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.