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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:48:35+00:00 2026-05-19T16:48:35+00:00

For my current project i need to have a table in which contains textfield

  • 0

For my current project i need to have a table in which contains textfield in each cell, the number of cells and textfield must be dynamic, it’s depends on the number of data in a MutuableArray. I have the textfield in cells working, but i can’t get/set the textfield value. I wonder if you guys can help me out or at least correct me what I did wrong? Thank’s alot in advance. See code snippets below:

// Adds textfield into cell

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

    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {
        NSUInteger row = indexPath.row;
        X10ArchiefIndexDefs *curIndex = [indexDefinities objectAtIndex:row];
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

        BOOL bShowSelection = ([curIndex.HasVasteWaarden isEqualToString:@"false"]);

        if (bShowSelection) {
            bShowSelection = !([curIndex.DataType isEqualToString:@"Datum"]);
        }

        if ([indexPath section] == 0) {
            if (bShowSelection) {
                cell.accessoryType = UITableViewCellAccessoryNone;
            } else {
                cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
            }

            UITextField *editField = [[UITextField alloc] initWithFrame:CGRectMake(110, 10, 185, 30)];
            editField.adjustsFontSizeToFitWidth = YES;
            editField.textColor = [UIColor blackColor];
            editField.placeholder = curIndex.Naam;
            editField.keyboardType = UIKeyboardTypeDefault;
            editField.returnKeyType = UIReturnKeyNext;
            editField.backgroundColor = [UIColor whiteColor];
            editField.autocorrectionType = UITextAutocorrectionTypeNo; // no auto correction support
            editField.autocapitalizationType = UITextAutocapitalizationTypeNone; // no auto capitalization support
            editField.textAlignment = UITextAlignmentLeft;
            editField.clearButtonMode = UITextFieldViewModeNever; // no clear 'x' button to the right
            editField.tag = [curIndex.UID intValue];

            [editField setEnabled: YES];
            [cell addSubview:editField];

            [editField release];
        }
    }

    return cell;
}

In some case i’m using popovercontroller to display list of data. User can select a value uit of the popup. This code is executed when there is a value selected:

- (void)selectedValue:(NSString *) value {

    //---update value of the text field ---
    //The first attempt it doesn't put the text to text field

    //static NSString *CellIdentifier = @"Cell";
    //UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    //
    //if (cell == nil) {
    //  cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    //}

    // second attempt it crashes 
    X10ArchiefIndexDefs *curIndex = [indexDefinities objectAtIndex:curRow.row];
    int index = [curIndex.UID intValue];
    UITextField *textField = (UITextField *) [curCell viewWithTag: index];
    if (textField) {
            [textField setText:value];
    }

    [textField release];

    [self.popOverController dismissPopoverAnimated:YES];
}

When cell is selected I’m making sure that the cell is saved for use later.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    X10ArchiefIndexDefs *curIndex = [indexDefinities objectAtIndex:indexPath.row];

    if (!curIndex) {
        return;
    }

    curRow = indexPath; // saves the selected row

    if ([curIndex.VasteWaarden count] > 0) {
        UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
        curCell = cell; // saves the selected cell

        CGRect frame = [cell.superview convertRect:cell.frame toView:self.view];

        self.detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];          
        detailViewController.delegate = self;
        self.popOverController = [[[UIPopoverController alloc] initWithContentViewController:detailViewController] autorelease];               

        X10ArchiefIndexDefs *curIndex = [indexDefinities objectAtIndex:indexPath.row];
        self.detailViewController.Values = curIndex.VasteWaarden;

        [self.popOverController presentPopoverFromRect:frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    }
}

Again thank’s alot in advance.

Cheers,
Inoel

  • 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-19T16:48:35+00:00Added an answer on May 19, 2026 at 4:48 pm

    In the second code snippet you are releasing the textField. You shouldn’t do this because you haven’t retained it. Because viewWithTag: simple gets a reference to the text field it doesn’t retain the textField. So you are releasing it more times that it has been retained, so the retainCount reaches 0 and the textfield is dealloced from memory. Then when you attempt it the second time there is no textfield in the memory.

    Just remove the:

    [textField release];
    

    From the second code snippet. If you don’t understand why, then read some articles about memory management (just google it). It takes some time to understand it fully, at least I know it took me a while 🙂

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

Sidebar

Related Questions

On my current project, which is a delivery system, I have a list of
Hey all, quick NHibernate question. In my current project, we have a denormalized table
I have a project which provides users with a list of current tasks that
In my current project (which is really small) i have 3 tables/ POCO entities
for my current project i need to consume messages from many destinations (from hundreds
In a current project i need to display PDFs in a webpage. Right now
Successfully used jquery-infinite-carousel in the past but for my current project I need it
I need to implement for current project some secure login in php. I wrote
In my current project (presentation, slide software) I need to be able to make
For our current J2EE project based on JBoss, we need to interface with a

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.