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

  • SEARCH
  • Home
  • 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 8092535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:18:23+00:00 2026-06-05T20:18:23+00:00

I have created a UITableView with a custom UITableViewCell . My cell includes one

  • 0

I have created a UITableView with a custom UITableViewCell. My cell includes one UIImageView on the left and UITextView on the right.

Inside UITableViewController, I set both image and text in tableview cellForRowAtIndexPath.

Everything shows fine but now I need to implement didSelectRowAtIndex and I need to distinguish if UIImageView or UITextView of the cell has been clicked.

Let’s say, image clicking is representing delete action and the rest of the cell editing action.

  • 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-05T20:18:24+00:00Added an answer on June 5, 2026 at 8:18 pm

    Rather than adding the gesture recognisers to each individual cell, you can add one to the table view and determine which cell was selected from the point of the users touch, and then determine if the user touched the image or the cell.

    First make sure your controller adopts the UIGestureRecognizerDelegate protocol.

    @interface MyTableViewController() <UIGestureRecognizerDelegate>
    @end
    

    Then add the UIGestureRecognizer to the UITableView when the view loads.

        - (void)viewDidLoad
    {
        [super viewDidLoad];
        UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
        singleTap.delegate = self;
        singleTap.numberOfTapsRequired = 1;
        singleTap.numberOfTouchesRequired = 1;
        [self.tableView addGestureRecognizer:singleTap];
    }
    

    This delegate method determines if the handleTap: method should be executed. If it can find an indexPath from the users touch, then it returns YES otherwise it returns NO.

    - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
    {
        UITableView *tableView = (UITableView *)gestureRecognizer.view;
        CGPoint p = [gestureRecognizer locationInView:gestureRecognizer.view];
        if ([tableView indexPathForRowAtPoint:p]) {
            return YES;
        }
        return NO;
    }
    

    Once we have determined if the user has clicked in a cell, the handleTap: method is called, which then decides if the user touched the image, or any other part of the cell.

    - (void)handleTap:(UITapGestureRecognizer *)tap
    {
        if (UIGestureRecognizerStateEnded == tap.state) {
            UITableView *tableView = (UITableView *)tap.view;
            CGPoint p = [tap locationInView:tap.view];
            NSIndexPath* indexPath = [tableView indexPathForRowAtPoint:p];
            [tableView deselectRowAtIndexPath:indexPath animated:NO];
            UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
            CGPoint pointInCell = [tap locationInView:cell];
            if (CGRectContainsPoint(cell.imageView.frame, pointInCell)) {
                // user tapped image
            } else {
                // user tapped cell
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a custom UITableViewCell , but when I dequeue the cell, sometimes
i have created a custom UITableViewCell , but when I dequeue the cell, sometimes
I have a grouped UITableView with custom cells (created by subclassing UITableViewCell ). I
I have a UITableView with custom cell. I have created seperate class with xib
I have a custom UITableViewCell which I created in Interface Builder. I am successfully
I'm using a custom UITableViewCell I've created to expand a cell when it's touched.
UITableView custom cell showing weird results? I have my code below. Everything was showing
I created a custom cell with IB In my interface, I have 3 UILabels
In my app, I have a UITableView and each UITableViewCell utilizes a custom background
I am facing this very weird problem, I have created a custom UITableViewCell on

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.