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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:33:52+00:00 2026-06-13T08:33:52+00:00

I have embedded textfields in cells and I have an edit button that is

  • 0

I have embedded textfields in cells and I have an edit button that is supposed to trigger a cell into an edit mode where I can edit the text in the cell.

What I need to do is loop through all the textfields and set the userInteractionEnabledto yes. I have done this here in the `setEditing:animated method:

- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{

[super setEditing:editing animated:animated];

if (editing)
{
    int tagNumber = 0;
    for (id cellTextField in [tableView visibleCells]) {
        UITextField *aField = (UITextField *)[cellTextField viewWithTag:tagNumber];
        aField.userInteractionEnabled = YES;
        tagNumber++;
    }

    self.editButtonItem.title = NSLocalizedString(@"Done", @"Done");
}
else
{
    self.editButtonItem.title = NSLocalizedString(@"Delete", @"Delete");
}
}

Then I need to somehow put all of those textFields back into the tableview cells. Hope someone can help.

Cheers.

  • 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-13T08:33:53+00:00Added an answer on June 13, 2026 at 8:33 am

    Realised I was being a bit stupid when I forgot the whole point of pointers.

    In the cellForRowAtIndexPath method, I added the UITextFields to an array (after adding them as subviews to the cells). Then in the edit button method, I just used fast enumeration to cycle through the array of textFields and changed the userInteractionEnabled property from there.

    Here is the code for creating the textfields:

    - (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *indexPath
    {
      // Configure the cell...
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    
      if (cell == nil)
      {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
      }
    
      cell.selectionStyle = UITableViewCellSelectionStyleNone;
      tf = nil;
    
      if (self.currentLevel == 0)
      {
            // create textfield
            tf = [self makeTextField:@"Some text"];          
    
            // add to subview
            [cell.contentView addSubview:tf];
    
    
            // Textfield dimensions
            tf.frame = CGRectMake(20, 12, 170, 30);
    
            //handle textFieldDidEndEditing
            tf.delegate = self;
    
            tf.userInteractionEnabled = NO;
    
            [textFieldArray addObject:tf];
      }
    
     }
    

    Here is the code for making them editable:

    //Edit Button
    -(void) editObject:(id)sender
    {
    
      if (editButton.title == @"Edit")
      {
        edit = TRUE;
    
        // make all textFields editable on click
        for (UITextField *textF in textFieldArray)
        {
            textF.userInteractionEnabled = YES;
        }        
        editButton.title = @"Done";
      }
      else
      {
        edit = FALSE;
    
        // make all textFields non-editable on click
        for (UITextField *textF in textFieldArray)
        {
            textF.userInteractionEnabled = NO;
        }
        editButton.title = @"Edit";
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UITextView embedded inside a grouped table view cell that I can't
I have embedded a ScrollView within a UIViewController which contains multiple text fields that
I have embedded a JTextArea on a JScrollPane and am using that JTextArea for
I need to get pointed in the right direction. I have embedded an Iron
I have an embedded device where i need to put my /var and /tmp
I have several embedded linux systems that I want to write a 'Who's Online?'
I have an Actionscript project that I was building using Flash CS4. I embedded
I have a project ongoing at the moment that uses dynamic text blocks to
I have embedded Lua in an Objective-C application using LuaObjCBridge. I need to know
What is the name of the tool that allowed VB.NET code to have embedded

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.