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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:45:58+00:00 2026-05-27T13:45:58+00:00

I’m loading my table from an XML feed in to an array then creating

  • 0

I’m loading my table from an XML feed in to an array then creating the cells as the code below shows. It can be really jerky when loading sometimes. I thought that was just the images downloading when I scroll but I removed them to test and sometimes it was still jerky. Can’t work out what I’m doing wrong!

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

    const NSInteger BOTTOM_LABEL_TAG = 1002;
    const NSInteger TEXT_FIELD_TAG = 1003;

    UILabel *Labelcompanyname;
    UILabel *Labeldistance;

    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil)
    {

        cell =
        [[[UITableViewCell alloc]
          initWithStyle:UITableViewCellStyleDefault
          reuseIdentifier:CellIdentifier]
         autorelease];


        const CGFloat LABEL_HEIGHT = 15;


        int spaceSize;

        if(currentType == @"categorySearch"){

                spaceSize = 57;
        }
        else {

                spaceSize = 34;
        }


        Labelcompanyname =
        [[[UILabel alloc]
          initWithFrame:
          CGRectMake(
                     spaceSize + 2.0 * cell.indentationWidth,
                     0.5 * (tableView.rowHeight - 2 * LABEL_HEIGHT)+10,
                     tableView.bounds.size.width -
                     spaceSize - 20.0,
                     LABEL_HEIGHT)]
         autorelease];
        [cell.contentView addSubview:Labelcompanyname];


        Labeldistance =[[[UILabel alloc]
                         initWithFrame:
                         CGRectMake(
                                    spaceSize + 2.0 * cell.indentationWidth,
                                    0.5 * (tableView.rowHeight - 2 * LABEL_HEIGHT)+40,
                                    tableView.bounds.size.width -
                                    spaceSize - 20.0,
                                    LABEL_HEIGHT)]
                        autorelease];
        if(currentType == @"categorySearch") {
            [cell.contentView addSubview:Labeldistance];

        } 


        Labelcompanyname.tag = BOTTOM_LABEL_TAG;
        Labelcompanyname.font = [UIFont systemFontOfSize:[UIFont labelFontSize] - 2];

        Labeldistance.tag = TEXT_FIELD_TAG;
        Labeldistance.font = [UIFont systemFontOfSize:[UIFont labelFontSize] - 2];

        cell.backgroundView = [[[UIImageView alloc] init] autorelease];
        cell.selectedBackgroundView = [[[UIImageView alloc] init] autorelease];
        cell.textLabel.numberOfLines=0;

    }
    else
    {
        Labelcompanyname = (UILabel *)[cell viewWithTag:BOTTOM_LABEL_TAG];
        Labeldistance = (UILabel *)[cell viewWithTag:TEXT_FIELD_TAG];   

    }

    PromotionObject *newObj1;
    newObj1=[totalArray objectAtIndex:indexPath.row];

    if(!newObj1.furtherURL){

        Labelcompanyname.text =[NSString stringWithFormat:@"%@", newObj1.companyname];
        Labeldistance.text =newObj1.distance;
    }
    else
    {
        Labelcompanyname.text =[NSString stringWithFormat:@"Load more results"];
        Labeldistance.text =@"";
    }



    NSURL *Imageurl = [NSURL URLWithString:[NSString stringWithFormat:@"%@", newObj1.locImage]];
    NSData *data = [NSData dataWithContentsOfURL:Imageurl];
    UIImage *img = [[[UIImage alloc] initWithData:data] autorelease];

    if(currentType == @"categorySearch"){

        cell.imageView.image = img;

    } else if(currentType == @"fullSearch") {

        cell.imageView.image = [UIImage imageNamed:@"newmap.png"];

    } else {

        cell.imageView.image = [UIImage imageNamed:@"business.png"];

    }


    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;

    return cell;
}   

Any help will be really appreciated

Tom

  • 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-27T13:45:59+00:00Added an answer on May 27, 2026 at 1:45 pm

    You definitely shouldn’t do anything that blocks the UI thread for significant time while loading cells. E.g. NSData *data = [NSData dataWithContentsOfURL:Imageurl];.

    I recommend loading your images into the data source in the background and reload/update the table/cells when the data has been downloaded. Would also be good to implement a cache for your images so you don’t have to download them again everytime the cell is loaded.

    If you need help with asynchronous image loading, search for that. Lot’s of stuff on SO.

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

Sidebar

Related Questions

Does anyone know how can I replace this 2 symbol below from the string
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I used javascript for loading a picture on my website depending on which small
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I am currently running into a problem where an element is coming back from
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.