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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:42:45+00:00 2026-05-22T18:42:45+00:00

Hii everyone! I have some text fields in each cell of the table view,

  • 0

Hii everyone!

I have some text fields in each cell of the table view, like this

enter image description here

If I enter some data into the text field and scroll the view up and down again, the data in the text field is set to null. Why does this happen, how can I avoid this?

Following is my code for cell construction

static NSString *CellIdentifier = @"Cell";

CustomCellStudentData *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {
    //  cell = [[[CustomCellStudentData alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
    cell = [[[CustomCellStudentData alloc] initWithFrame:CGRectZero reuseIdentifier:nil] autorelease];
}
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];

switch(indexPath.section)
{
    case 0:
        switch (indexPath.row) 
        {
            case 0:
            {
                tfText[0] = [[UITextField alloc] initWithFrame:CGRectMake(125,15, 170, 40)];
                cell.accessoryView = tfText[0];
                tfText[0].delegate = self;
                tfText[0].text = @"";
                tfText[0].placeholder = @"<Student Name>";

                cell.primaryLabel.text = @"Student Name: ";
            } 
                break;
            case 1: 
            {
                tfText[1] = [[UITextField alloc] initWithFrame:CGRectMake(125,15, 170, 40)];
                cell.accessoryView = tfText[1];
                tfText[1].delegate=self;
                tfText[1].placeholder = @"<Student Age>";

                cell.primaryLabel.text = @"Student Age: ";
            } 
                break;
        }

Thanx in advance

  • 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-22T18:42:46+00:00Added an answer on May 22, 2026 at 6:42 pm

    when the cell is scrolled out of window, it may be released, so you must save the input in somewhere and read from there in cell construction method.

    Take one cell with one textfield as example:
    first I declare a NSString in my interface,and apply to UITextFieldDelegate protocol:

    @interface someInterface : UITableViewController
    <UITextFieldDelegate>
    {
        NSString* contentOfTextField;
    }
    @property(nonatomic,retain) NSString* contentOfTextField;
    @end
    

    then, in cellForRowAtIndex:

        static NSString *CellIdentifier = @"Cell";
    
        CustomCellStudentData *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
        }
        UITextField* field = [[UITextField alloc] initWithFrame:CGRectMake(125,15, 170, 40)];
        field.delegate = self;
        field.tag = 1;
    
        field.text = self.contentOfTextField;
        [cell addSubView:field];
        [field release];
        return cell;
    

    At last, apply this to update contentOfTextField everytime you edit it:

    -(void)textFieldDidEndEditing:(UITextField*)textField
    {
        UITableViewCell* cell = [self.tableView cellForRowAtIndexPath(/*the indexPath of your cell*/)];
        UITextField* t = (UITextField*)[cell viewWithTag:1];
        self.contentOfTextField = t.text;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hii every one i have created a data entry screen like this in which
Hii... I would like to have the text hyper linked in between the content
hii i am using ajax file upload in this code <script type=text/javascript src=fileuploader.js></script> <script
Hii i have this code : $handle = popen(php -q nah.php -p=. '$part' .
Hii all,, I have some project that requires me to do Image processing, I
html code <table border=0 class=commentbox> <tr> <td>Some Item text </td> </tr> <tr> <td> <div
Hii , I have a small php form. I need it to come in
hii I have a 680 buttons in a page, and I want to run
Hii,, I need a help. I have a master page and i am changing
Hii, I have created a class file with a name space of name1. I

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.