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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:43:27+00:00 2026-05-31T20:43:27+00:00

Alright, I know this question has been asked before, but mine has a different

  • 0

Alright, I know this question has been asked before, but mine has a different issue than the others.

I have a text field inside of a custom tableview cell that I need to save to an array after the number pad is dismissed. Since the number pad has no done button, I had to implement a touch event to dismiss the number pad. That means my -textFieldDidEndEditing is not firing. Here is the relevant code:

in my viewController.h

itemData *tempItem; //A custom object    
UITableView *itemsListTable;
NSMutableArray *listData;

in my viewController.m

    - (UITableViewCell *)tableView:(UITableView *)tableView
             cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {

       static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";


        UITableViewCell *cell = [itemsListTable
                                 dequeueReusableCellWithIdentifier:SimpleTableIdentifier];

        if (cell == nil) {
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault
                                          reuseIdentifier:SimpleTableIdentifier];


        NSInteger row = indexPath.row;
        tempItem = [listData objectAtIndex:row];
        cell.textLabel.text = [tempItem getItemName];


        UITextField *quantityTextField = [[UITextField alloc] initWithFrame:CGRectMake(275, 8, 35, 27)];
        quantityTextField.keyboardType = UIKeyboardTypeNumberPad;
        quantityTextField.borderStyle = UITextBorderStyleRoundedRect;
        quantityTextField.returnKeyType = UIReturnKeyDone;
        quantityTextField.text = [NSString stringWithFormat:@"%d", tempItem.getItemQuantity];
        quantityTextField.textAlignment = UITextAlignmentCenter;


        [cell addSubview:quantityTextField];
        } 


        return cell;

    }

-(void)touchesEnded: (NSSet *)touches withEvent: (UIEvent *)event {
[[self itemsListTable] endEditing:YES];
    }
- (void)textFieldDidEndEditing:(UITextField *)textField {

    UITableViewCell *cell = (UITableViewCell*)textField.superview;

    NSIndexPath *indexPath = [self.itemsListTable indexPathForCell:cell];

    tempItem = [listData objectAtIndex:indexPath.row];

    NSLog(@"Did End Editing");
    [tempItem setItemQuantity:[textField.text intValue]]; //save textfield to object as intValue

    [listData replaceObjectAtIndex:indexPath.row withObject:tempItem]; //save object to array
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        [listData removeObjectAtIndex:indexPath.row];
        [itemsListTable reloadData];
    }    
}

- (NSInteger)tableView:(UITableView *)tableView
 numberOfRowsInSection:(NSInteger)section
{
    numberOfItems.text = [NSString stringWithFormat:@"%d",listData.count];

    return [self.listData count];
}
  • 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-05-31T20:43:28+00:00Added an answer on May 31, 2026 at 8:43 pm

    When your touch event dismisses the keyboard, also call [self textFieldDidEndEditing:], or if you need to know which text field had focus last, keep a reference by defining a UITextField object that you set to the current text field that has first responder in the textFieldDidBeginEditing delegate function. Like this:

    //In .h
    UITextField * txtReference;
    
    //In .m
    - (void)textFieldDidBeginEditing:(UITextField *)textField{
        txtReference = textField;
    }
    
    //In the function that dismisses the keyboard put:
    [self textFieldDidEndEditing:txtReference];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, I know questions like this have probably been asked dozens of times, but
Alright I know this is more than likely a amateur question but I have
Alright I know that the .closest() have been discussed before, but I have been
Alright, I know this is a simple question, but I can't seem to get
Alright, I know I've asked similar questions, but I feel this is hopefully a
Alright, I know there's a simple way to do this, but it's been years
Alright, i dont know how to explain it well.. but i have a switch
Alright, nub question. I know. Basic response might be Convert.ToInt32(string); But naturally, C# does
I know this question might sound quite stupid, but I've tried my best and
Alright I know this isn't 100% related to programming (the Excel book in question

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.