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

  • Home
  • SEARCH
  • 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 9173145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:31:15+00:00 2026-06-17T16:31:15+00:00

I have created a table view that display data from array.but now when i

  • 0

I have created a table view that display data from array.but now when i scroll table view than my data change unacceptably.

So how can i prevent tableview to refresh every time when scroll and set all the data first time when table view created.

here is my code:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
ExampleAppDataObject* theDataObject = [self theAppDataObject];    // Return the number of sections.
    return theDataObject.vendorTableAry.count;  //this is return value of array and it will be more than 2 which help to create section
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.
    return 4;   // i want only 4 row in each section
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    ExampleAppDataObject* theDataObject = [self theAppDataObject]; 

    static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";

    UITableViewCell * cell = [tableView
                              dequeueReusableCellWithIdentifier: SimpleTableIdentifier];

    if(cell == nil) {

        cell = [[UITableViewCell alloc]
                 initWithStyle:UITableViewCellStyleDefault
                 reuseIdentifier:SimpleTableIdentifier];

        /*cell = [[[UITableViewCell alloc]
         initWithStyle:UITableViewCellStyleSubtitle
         reuseIdentifier:SimpleTableIdentifier] autorelease];
         */

        if (indexPath.row==0) {
            UILabel * vendorLbl = [[UILabel alloc] initWithFrame:CGRectMake(10, 2, 60, 39)];
            [[vendorLbl layer] setCornerRadius:5.0f];
            //[vendorLbl setFont:[UIFont fontWithName:@"Helvetica-Bold" size:13.0]];
            vendorLbl.backgroundColor = [UIColor clearColor];


            [vendorLbl setText:@"vender"];

            [cell.contentView addSubview:vendorLbl];


            UILabel * columnLbl = [[UILabel alloc] initWithFrame:CGRectMake(80, 2, 10, 39)];

            columnLbl.backgroundColor = [UIColor clearColor];


            [columnLbl setText:@":"];

            [cell.contentView addSubview:columnLbl];


            UILabel * vendorValueLbl = [[UILabel alloc] initWithFrame:CGRectMake(98, 2, 195, 39)];

            [[vendorValueLbl layer] setCornerRadius:5.0f];
            //[vendorLbl setFont:[UIFont fontWithName:@"Helvetica-Bold" size:13.0]];
            vendorValueLbl.backgroundColor = [UIColor clearColor];


            [vendorValueLbl setText:[theDataObject.vendorTableAry objectAtIndex:indexPath.section]];

            [cell.contentView addSubview:vendorValueLbl];
        }
        if (indexPath.row==1) {
            UILabel * vendorLbl = [[UILabel alloc] initWithFrame:CGRectMake(10, 2, 60, 39)];
            [[vendorLbl layer] setCornerRadius:5.0f];
            //[vendorLbl setFont:[UIFont fontWithName:@"Helvetica-Bold" size:13.0]];
            vendorLbl.backgroundColor = [UIColor clearColor];


            [vendorLbl setText:@"Gallons"];

            [cell.contentView addSubview:vendorLbl];


            UILabel * columnLbl = [[UILabel alloc] initWithFrame:CGRectMake(80, 2, 10, 39)];

            columnLbl.backgroundColor = [UIColor clearColor];


            [columnLbl setText:@":"];

            [cell.contentView addSubview:columnLbl];


            UILabel * vendorValueLbl = [[UILabel alloc] initWithFrame:CGRectMake(98, 2, 195, 39)];

            [[vendorValueLbl layer] setCornerRadius:5.0f];
            //[vendorLbl setFont:[UIFont fontWithName:@"Helvetica-Bold" size:13.0]];
            vendorValueLbl.backgroundColor = [UIColor clearColor];


            [vendorValueLbl setText:[theDataObject.gallonsTableAry objectAtIndex:indexPath.section]];

            [cell.contentView addSubview:vendorValueLbl];
        }
        if (indexPath.row==2) {
            UILabel * vendorLbl = [[UILabel alloc] initWithFrame:CGRectMake(10, 2, 60, 39)];
            [[vendorLbl layer] setCornerRadius:5.0f];
            //[vendorLbl setFont:[UIFont fontWithName:@"Helvetica-Bold" size:13.0]];
            vendorLbl.backgroundColor = [UIColor clearColor];


            [vendorLbl setText:@"Route"];

            [cell.contentView addSubview:vendorLbl];


            UILabel * columnLbl = [[UILabel alloc] initWithFrame:CGRectMake(80, 2, 10, 39)];

            columnLbl.backgroundColor = [UIColor clearColor];


            [columnLbl setText:@":"];

            [cell.contentView addSubview:columnLbl];


            UILabel * vendorValueLbl = [[UILabel alloc] initWithFrame:CGRectMake(98, 2, 195, 39)];

            [[vendorValueLbl layer] setCornerRadius:5.0f];
            //[vendorLbl setFont:[UIFont fontWithName:@"Helvetica-Bold" size:13.0]];
            vendorValueLbl.backgroundColor = [UIColor clearColor];


            [vendorValueLbl setText:[theDataObject.routeTableAry objectAtIndex:indexPath.section]];

            [cell.contentView addSubview:vendorValueLbl];
        }
        if (indexPath.row==3) {
            UILabel * vendorLbl = [[UILabel alloc] initWithFrame:CGRectMake(10, 2, 60, 39)];
            [[vendorLbl layer] setCornerRadius:5.0f];
            //[vendorLbl setFont:[UIFont fontWithName:@"Helvetica-Bold" size:13.0]];
            vendorLbl.backgroundColor = [UIColor clearColor];


            [vendorLbl setText:@"Date"];

            [cell.contentView addSubview:vendorLbl];


            UILabel * columnLbl = [[UILabel alloc] initWithFrame:CGRectMake(80, 2, 10, 39)];

            columnLbl.backgroundColor = [UIColor clearColor];


            [columnLbl setText:@":"];

            [cell.contentView addSubview:columnLbl];


            UILabel * vendorValueLbl = [[UILabel alloc] initWithFrame:CGRectMake(98, 2, 195, 39)];

            [[vendorValueLbl layer] setCornerRadius:5.0f];
            //[vendorLbl setFont:[UIFont fontWithName:@"Helvetica-Bold" size:13.0]];
            vendorValueLbl.backgroundColor = [UIColor clearColor];


            [vendorValueLbl setText:[theDataObject.dateTableAry objectAtIndex:indexPath.section]];

            [cell.contentView addSubview:vendorValueLbl];
        }

    }
    return cell;
}
  • 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-17T16:31:16+00:00Added an answer on June 17, 2026 at 4:31 pm

    Just set dequeueReusableCellWithIdentifier to nil like below..

    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier: nil];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created programme in which we navigate from table view to a simple
Hey guys, I have an application that I want to display some data from
I have a UITableView showing data from a plist file. For this table view,
I've created a table from a TcxGrid with a simple table view. The data
I have a php page that recalls data from an SQL table, and then
I have an attendance table that displays how I want it to display but
I have a custom tableview cell created programmatically that consists of: a background view
I have created a table view with navigation controller. I want to link table
I am new to iPhone development. I have created a table view in a
I have created a TableView(Grouped Table View). And I can list the items in

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.