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 8534087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:06:50+00:00 2026-06-11T10:06:50+00:00

I have a UITableView that has 2 different customcell definitions. One is a single

  • 0

I have a UITableView that has 2 different customcell definitions. One is a single UITextField and the other has 4 UITextFields

userInteractionEnabled is manually set to enable cell level touch navigation, and I handle the UI interaction within didSelectRowAtIndexPath to the first responder to the relevant cell

This all worked fine when I was using just the one customcell (EditableCustomCell) with one UITextField (editableTextField), but now I have a customcell (LatLonCustomCell) with 4 UITextFields (degrees, minutes, seconds, cartesian), I cannot determine which field has been touched in order to set becomeFirstResponder

(currently I’m defaulting in the first textfield called degrees during debug)

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{      
  [prevField resignFirstResponder];
  prevField.userInteractionEnabled = NO;

  if(indexPath.section == kFirstSection && (indexPath.row == kLatitudeRow || indexPath.row == kLongitudeRow)) {
    LatLonCustomCell *customCell = (LatLonCustomCell *)[MyTableView cellForRowAtIndexPath:indexPath];
    currField = customCell.degrees; // need to set correct field here
  } else {
    EditableCustomCell *customCell = (EditableCustomCell *)[MyTableView cellForRowAtIndexPath:indexPath];
    currField = customCell.editableTextField;
  }

  currFieldIndexPath = [NSIndexPath indexPathForRow:indexPath.row inSection:indexPath.section];
  currField.userInteractionEnabled = YES;
  [currField becomeFirstResponder];

}

  • 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-11T10:06:51+00:00Added an answer on June 11, 2026 at 10:06 am

    OK, so for those that come across this with the same or similar problem, I have finally made a breakthrough

    I decided that I was going to need to capture the X/Y coordinates of the touch prior to the didSelectRowAtIndexPath being called. This way I could then determine which UITextField the touch occurred in by checking the touch against the “bounds” of the textfield

    After some random searching, I found that a VERY easy way of capturing ANY touch event in the viewcontroller (as touchesBegan only occurred in the custom overridden UITableViewCell class and I knew not how to pass this back up the chain Cell > TableView > Scroll View > Controller)

    By adding this to the viewDidLoad method:

    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)];
    tapGesture.numberOfTapsRequired = 1;
    // Pass the tap through to the UITableView
    tapGesture.cancelsTouchesInView = NO;
    [self.view addGestureRecognizer:tapGesture];
    

    This captures all touches, calling the handleTapGesture method

    Then within this method it was simply a case of checking if the touch was within the bounds of the tableview, and if so, determine the indexPath for the point touched and then check against the bounds of the object required, below is a simplified version of what I came up with

    -(void)handleTapGesture:(UITapGestureRecognizer *)tapGesture {
    
      CGPoint tapLoc = [tapGesture locationInView:self.tableView];
    
      if([MyTableView indexPathForRowAtPoint:tapLoc]) {
        // Tap still handled by the UITableView delegate method
    
        NSIndexPath *indexPath = [MyTableView indexPathForRowAtPoint:tapLoc];
    
        if(indexPath.section == 0 && (indexPath.row == kLatitudeRow || indexPath.row == kLongitudeRow)) {
          LatLonCustomCell *customCell = (LatLonCustomCell *)[MyTableView cellForRowAtIndexPath:indexPath];
          UIScrollView *scrollView = (UIScrollView *)self.view;
          CGRect rc;
    
          // Degrees
          rc = [customCell.degrees convertRect:[customCell.degrees bounds] toView:scrollView];
    
          if (tapLoc.x >= rc.origin.x && tapLoc.y >= rc.origin.y && tapLoc.x <= (rc.origin.x + rc.size.width) && tapLoc.y <= (rc.origin.y + rc.size.height)) {
            NSLog(@"touch within bounds for DEGREES");
            touchField = customCell.degrees;
          }
    
    // Repeat for other textfields here ....
    
    ....
    

    In my code I save the field within touchField, as within the didSelectRowAtIndexPath code, I am already handling prevField/currField values to control the enabling/disabling of userInteractionEnabled and to set the currField as becomeFirstReponder

    Hope this proves helpful to someone 🙂

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

Sidebar

Related Questions

I have a UITableView that has five sections. Just as the title describes cellForRowAtIndexPath
Is it possible to have a UITableView that has a fixed height for all
I have a custom UITableView cell that has a UIImageView sized to the width
I have an iOS app with a UITableView that has flexible width, which allow
I have a UITableView that displays single large images in each cell. The names
In my iPhone app I have a UIViewController that has a UITableView and another
I've a UITableView which when a cell has the same content that other, this
i need two kinds of UITableViewCell that has different height: a) One with a
So I have one NSArray that has names of documents to be presented in
I have a UITableView that has a disclosure button on every row. When the

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.