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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:44:07+00:00 2026-05-26T17:44:07+00:00

Why tableview data are overlapping? i have attached my code. If i explain my

  • 0

Why tableview data are overlapping? i have attached my code.

If i explain my code again then

  1. xml data are in records array which are displaying in tableview.
  2. First time when program execute then data are in right place but when i start scroll vertically the data start to display in various cell.suppose first cell shows in last cell,second cell data shows in first cell…..so on.

NOTE THAT: For overlapping problem i also used switch and viewwithtag but still now tableview data start to display in wrong cell when i start scrolling on UITableview.

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
   // cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
    cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:15.0];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    NSLog(@"%d",indexPath.section);

    switch (indexPath.section) {
        case 0:
            order_cellView = [[UIView alloc] initWithFrame:CGRectMake(5, 5, cell.frame.size.width,cell.frame.size.height) ];
            order_cellView.backgroundColor = [UIColor redColor];
            order_cellView.tag =1000;

            NSLog(@"index path 0");
            CGRect frame;
            frame.origin.x =0;
            frame.origin.y = 10;
            frame.size.height = 30;
            frame.size.width = 230;

            CGRect valueFrame;
            valueFrame.origin.x =237;
            valueFrame.origin.y = 5;
            valueFrame.size.height = 30;
            valueFrame.size.width = 80;


            for(int m=0;m<numberOfProduct;m++){
                NSLog(@"for loop here");
                productLabel = [[UILabel alloc] initWithFrame:frame];
                productLabel.tag = m;
                productLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:13];
                productLabel.backgroundColor = [UIColor clearColor];
                productLabel.lineBreakMode = UILineBreakModeCharacterWrap;
                productLabel.numberOfLines = 2;
                productLabel.textAlignment = UITextAlignmentCenter;
                [order_cellView addSubview:productLabel];
                productLabel.text =  [NSString stringWithFormat:@"%@ x %@ x %@",[[products objectAtIndex:m] objectAtIndex:1],[[products objectAtIndex:m] objectAtIndex:2],[[products objectAtIndex:m] objectAtIndex:3]];
                frame.origin.y += 45;

                productValueLabel = [[UILabel alloc] initWithFrame:valueFrame];
                productValueLabel.tag = m+2;
                productValueLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:13];
                productValueLabel.backgroundColor = [UIColor clearColor];
                productValueLabel.lineBreakMode = UILineBreakModeCharacterWrap;
                productValueLabel.numberOfLines = 2;
                productValueLabel.textAlignment = UITextAlignmentCenter;
                productValueLabel.text = [NSString stringWithFormat:@"%@",[[products objectAtIndex:m] objectAtIndex:5]];
                [order_cellView addSubview:productValueLabel];
                valueFrame.origin.y += 45;
            }
            [cell.contentView addSubview:order_cellView];
            break;
        case 1:
            email_cellView = [[UIView alloc] initWithFrame:CGRectMake(5, 5, cell.frame.size.width,cell.frame.size.height) ];
            email_cellView.backgroundColor = [UIColor clearColor];
            email_cellView.tag =1001;


            emailAdressLabel = [[UILabel alloc] initWithFrame:CGRectMake(2, 0, cell.frame.size.width, cell.frame.size.height)];
            emailAdressLabel.tag = 100;
            emailAdressLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:13];
            emailAdressLabel.backgroundColor = [UIColor clearColor];
            emailAdressLabel.lineBreakMode = UILineBreakModeCharacterWrap;
            emailAdressLabel.numberOfLines = 2;
            emailAdressLabel.textAlignment = UITextAlignmentLeft;
            emailAdressLabel.text = [NSString stringWithFormat:@"%@",[[records objectAtIndex:0] objectAtIndex:6]];
            [email_cellView addSubview:emailAdressLabel];
            [cell.contentView addSubview:email_cellView];

            break;
        case 2:

            phoneNumberLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 2, cell.frame.size.width, cell.frame.size.height)];
            phoneNumberLabel.tag = 101;
            phoneNumberLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:13];
            phoneNumberLabel.backgroundColor = [UIColor clearColor];
            phoneNumberLabel.lineBreakMode = UILineBreakModeCharacterWrap;
            phoneNumberLabel.numberOfLines = 1;
            phoneNumberLabel.textAlignment = UITextAlignmentLeft;
            phoneNumberLabel.text = [NSString stringWithFormat:@"%@",[[records objectAtIndex:0] objectAtIndex:7]];
            [cell.contentView addSubview:phoneNumberLabel];

            break;
        case 3:
            billingDetails = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 160, cell.frame.size.height)];
            billingDetails.tag = 102;
            billingDetails.font = [UIFont fontWithName:@"Arial-BoldMT" size:13];
            billingDetails.backgroundColor = [UIColor clearColor];
            billingDetails.lineBreakMode = UILineBreakModeCharacterWrap;
            billingDetails.numberOfLines = 4;
            billingDetails.textAlignment = UITextAlignmentLeft;
            billingDetails.text = [NSString stringWithFormat:@"%@",[[records objectAtIndex:0] objectAtIndex:4]];
            [cell.contentView addSubview:billingDetails];
            break;
        case 4:
            shippingDetails = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 160, cell.frame.size.height)];
            shippingDetails.tag = 103;
            shippingDetails.font = [UIFont fontWithName:@"Arial-BoldMT" size:13];
            shippingDetails.backgroundColor = [UIColor clearColor];
            shippingDetails.lineBreakMode = UILineBreakModeCharacterWrap;
            shippingDetails.numberOfLines = 4;
            shippingDetails.textAlignment = UITextAlignmentLeft;
            shippingDetails.text = [NSString stringWithFormat:@"%@",[[records objectAtIndex:0] objectAtIndex:5]];
            [cell.contentView addSubview:shippingDetails];

            break;
        case 5:
            orderStatus = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, cell.frame.size.width, cell.frame.size.height)];
            orderStatus.tag = 104;
            orderStatus.font = [UIFont fontWithName:@"Arial-BoldMT" size:13];
            orderStatus.backgroundColor = [UIColor clearColor];
            orderStatus.lineBreakMode = UILineBreakModeCharacterWrap;
            orderStatus.numberOfLines = 1;
            orderStatus.textAlignment = UITextAlignmentLeft;
            orderStatus.text = [NSString stringWithFormat:@"%@",[[records objectAtIndex:0] objectAtIndex:19]];
            [cell.contentView addSubview:orderStatus];

            break;
        case 6:
            deleteOrder = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, cell.frame.size.width, cell.frame.size.height)];
            deleteOrder.tag = 110;
            deleteOrder.font = [UIFont fontWithName:@"Arial-BoldMT" size:13];
            deleteOrder.backgroundColor = [UIColor clearColor];
            deleteOrder.lineBreakMode = UILineBreakModeCharacterWrap;
            deleteOrder.numberOfLines = 1;
            deleteOrder.textAlignment = UITextAlignmentLeft;
            deleteOrder.text = [NSString stringWithFormat:@"%@",[[records objectAtIndex:0] objectAtIndex:19]];
            [cell.contentView addSubview:deleteOrder];

            break;

        default:
            break;
    }       
}

switch (indexPath.section) {
    case 0:
        order_cellView = (UIView *)[cell.contentView viewWithTag:1000];
        for(int m=0;m<numberOfProduct;m++){
            productLabel = (UILabel *)[order_cellView viewWithTag:m];
            productValueLabel = (UILabel *)[order_cellView viewWithTag:m+2];
        }
        if(indexPath.section == 0){
            for(int m=0;m<numberOfProduct;m++){
                productLabel.text =  [NSString stringWithFormat:@"%@ x %@ x %@",[[products objectAtIndex:m] objectAtIndex:1],[[products objectAtIndex:m] objectAtIndex:2],[[products objectAtIndex:m] objectAtIndex:3]];
                productValueLabel.text = [NSString stringWithFormat:@"%@",[[products objectAtIndex:m] objectAtIndex:5]];
            }
        }
        break;
    case 1:
        email_cellView = (UIView *)[cell.contentView viewWithTag:1001];
        emailAdressLabel = (UILabel *)[email_cellView viewWithTag:100];
        emailAdressLabel.text = [NSString stringWithFormat:@"%@",[[records objectAtIndex:0] objectAtIndex:6]];      
        break;
    case 2:
        phoneNumberLabel = (UILabel *)[cell.contentView viewWithTag:101];
        phoneNumberLabel.text = [NSString stringWithFormat:@"%@",[[records objectAtIndex:0] objectAtIndex:7]];
        break;
    case 3:
        billingDetails = (UILabel *)[cell.contentView viewWithTag:102];
        billingDetails.text = [NSString stringWithFormat:@"%@",[[records objectAtIndex:0] objectAtIndex:4]];
        break;
    case 4:
        shippingDetails = (UILabel *)[cell.contentView viewWithTag:103];
        shippingDetails.text = [NSString stringWithFormat:@"%@",[[records objectAtIndex:0] objectAtIndex:5]];
        break;
    case 5:
        orderStatus = (UILabel *)[cell.contentView viewWithTag:104];
        orderStatus.text = [NSString stringWithFormat:@"%@",[[records objectAtIndex:0] objectAtIndex:19]];
        break;
    case 6:
        deleteOrder = (UILabel *)[cell.contentView viewWithTag:110];
        deleteOrder.text = [NSString stringWithFormat:@"%@",[[records objectAtIndex:0] objectAtIndex:19]];
        break;
    default:
        break;
}

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-05-26T17:44:07+00:00Added an answer on May 26, 2026 at 5:44 pm

    I think your main problem is that you have seven different “types” of cell but only one “reuse identifier.” This means that an order cell could be later reused as a delete order cell. However, when reused, the cell won’t necessarily have all the elements it needs to display fully.

    For example, email cell has a tag of 1001 and delete cell has a tag of 110, but not vice-versa.

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

Sidebar

Related Questions

i have a tableview application loaded with core data feltching objects and i wanna
I have a UINavigationController consisting of a tableview I want to load some data
I have a tableview with data, that i post to the app engine database.
i have made one list of images + respective data in tableview. it takes
So I have a Titanium.UI.tableview in my main window in my tab group which
I have a TableView loading a custom cell and loading the data from a
I have ipad application which has 3 tableviews with holds data like label,image,property lists
How can I pass the first tableview row data to second detail view row
i have 2 buttons A and B both display tableview and data initially same
I have a tableview with four sections first section has 7 rows in that

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.