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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:20:15+00:00 2026-05-20T18:20:15+00:00

i am displaying array of data in a table view. my code for that

  • 0

i am displaying array of data in a table view.

my code for that is like this.

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

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
    }

    // Set up the cell


    CGRect labelFrame = CGRectMake(0,0 , 100, 25);    
   itemNameLabel = [[[UILabel alloc] initWithFrame:labelFrame] autorelease];

    itemNameLabel.textAlignment = UITextAlignmentLeft;
    itemNameLabel.backgroundColor = [UIColor clearColor];
    itemNameLabel.text = [tableData objectAtIndex:indexPath.row];
    CGRect anotherLabelFrame = CGRectMake(120, 0, 100, 25);
    quantityLabel = [[[UILabel alloc] initWithFrame:anotherLabelFrame] autorelease];

    quantityLabel.textAlignment = UITextAlignmentLeft;
    quantityLabel.backgroundColor = [UIColor clearColor];
    MyGroceryListAppDelegate *appDelegate = (MyGroceryListAppDelegate *)[[UIApplication sharedApplication] delegate];
    Category *obj = (Category *)[appDelegate.itemsList objectAtIndex:indexPath.row];

    quantityLabel.text = [NSString stringWithFormat:@"%d",obj.quantity];
    [cell.contentView addSubview:itemNameLabel];
    [cell.contentView addSubview:quantityLabel];


    return cell;
} 

how can i resolve this.

can any one please help me.

Thank u in advance.

i am giving text for itemNameLabel is using array and for quantityLabel using class object.

so,when i scrolling table view the array names are override on other label,but quantity label is not overriding because it is from class.

i need to display itemNameLabel from array since it changes it value.

when i scroll table view my tableview is looking like this.mytableview

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

    Ideally you should alloc all lable in this section

     if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
    }
    

    and in the else part you should just Tag those labels and reuse after it but there is another short and sweet way
    if Application is not much resource consuming

    change

      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    

    to

     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 am displaying a scrolled data table in a web page. This table has
I have a global declared array and loading that array in table view but
When displaying all articles of a specific month (given through the urls like this
Why tableview data are overlapping? i have attached my code. If i explain my
Hello I am taking records from core data entity and displaying it in tableview.
I am using custom UITableview concept to show data in cell of tableview. My
I'm trying to have a Table View displaying the content of a generic SQLite
Friends, I am displaying an array in ListView. I change data of array dynamically
Say I have an array of strings I am displaying the following data in
Lets see if I can explain this. I am displaying a table in PHP

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.