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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:50:47+00:00 2026-05-31T23:50:47+00:00

I am trying to implement UITableview based application. In my tableView their is 10

  • 0

I am trying to implement UITableview based application. In my tableView their is 10 Section and each section having one row.
I want implement each section have Different type of ContentView(1-8 same ContentView 9th section Different ContentView). I did this code For that.

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 10;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

    return 1;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier1 = @"Cell1";
    static NSString *CellIdentifier2 = @"Cell2";
    UITextField *textField;
    UITextView *textView;
    NSUInteger section=[indexPath section];
    if(section == 9){
        UITableViewCell *cell=[self.tableView cellForRowAtIndexPath:indexPath];
        //UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier1];
        if(cell==nil){
            cell=[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier1]autorelease];
            textView=[[UITextView alloc]initWithFrame:CGRectMake(5, 5, 290, 110)];
            [textView setBackgroundColor:[UIColor scrollViewTexturedBackgroundColor
                                          ]];
            [textView setTag:([indexPath section]+100)];
            [cell.contentView addSubview:textView];
        }else{
            textView=(UITextView*)[cell.contentView viewWithTag:([indexPath section]+100)];
        }
        return cell;
    }else {
        UITableViewCell *cell=[self.tableView cellForRowAtIndexPath:indexPath];
       // UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier2];
        if(cell==nil){
            cell=[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier2]autorelease];
            textField=[[UITextField alloc]initWithFrame:CGRectMake(5, 5, 290, 50)];
            [textField setBackgroundColor:[UIColor scrollViewTexturedBackgroundColor]];
            [textField setTag:([indexPath section]+100)];
            [cell.contentView addSubview:textField];
        }else{
            textField=(UITextField*)[cell.contentView viewWithTag:([indexPath section]+100)];

        }

        return cell;
    }  


    return nil;

}

My problem are:
1. After type some thing in the UITextField/UITextView i am scrolling in the UITableView. that time all data in the UITableViewCell(UITextField/UITextView) was lose, except last cell data.
2. If i create cell

 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

Instead of

 UITableViewCell *cell=[self.tableView cellForRowAtIndexPath:indexPath];

Data will repeating . How can i over come this problem?

  • 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-31T23:50:48+00:00Added an answer on May 31, 2026 at 11:50 pm

    This line:

    UITableViewCell *cell=[self.tableView cellForRowAtIndexPath:indexPath];
    

    Should never appear in your data source cellForRowAtIndexPath method.

    Apart from that, your code is OK, except that you are not setting the text field value anywhere. You need a model (such as an array of strings for the 10 textfield values). This model should be updated when the textfields are edited, and in your method above you copy the value back out of the model and into the textfield’s text property:

    textfield.text = [self.modelArray objectAtIndex:indexPath.section];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement UITableView based Application.For that I select UITableViewStyle is Group.In
I am trying to implement -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath So far this is what
I'm trying to make my Core data backed UITableView have reorder ability, After implement
I have been trying to implement a comment engine in my app (UItableView) but
I have a UITableView with a list of items, each having it's own image.
It is my fervent dream to have a UITableView with different row sizes, determined
Trying to implement a UITableView of names similar to the built-in Contacts iPhone app
trying to implement a dialog-box style behaviour using a separate div section with all
I'm currently trying to implement a UITableView with a delegate and data source that
I'm trying to implement a UISearchBar within a UITableView , which behaves like 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.