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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:47:01+00:00 2026-05-16T05:47:01+00:00

Almost sorted with my 1st app, just a simple news app but when I

  • 0

Almost sorted with my 1st app, just a simple news app but when I load it onto my iPhone the scroll seems jerky can someone have a look at my function and see if i’m doing something wrong.

I need the image on the right hand side thats why i’m using custom cells.

Thanks
For any help

    #define DATELABEL_TAG 1 #define MAINLABEL_TAG 2 #define PHOTO_TAG 3


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

{

static NSString *MainNewsCellIdentifier = @"MainNewsCellIdentifier";


UILabel *mainLabel, *dateLabel;

UIImageView *photo;


    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: MainNewsCellIdentifier];


    if (cell == nil) 

{

        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier: MainNewsCellIdentifier] autorelease];

cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;


dateLabel = [[[UILabel alloc] initWithFrame:CGRectMake(15.0,15.0,170.0,15.0)] autorelease];

dateLabel.tag = DATELABEL_TAG;

dateLabel.font = [UIFont systemFontOfSize:10.0];

dateLabel.textAlignment = UITextAlignmentLeft;

dateLabel.textColor = [UIColor darkGrayColor];

dateLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin; //| UIViewAutoresizingFlexibleHeight;

[cell.contentView addSubview:dateLabel]; 


mainLabel = [[[UILabel alloc] initWithFrame:CGRectMake(15.0,28.0,170.0,60.0)] autorelease];

mainLabel.tag = MAINLABEL_TAG;

mainLabel.font = [UIFont boldSystemFontOfSize:14.0];

mainLabel.textColor = [UIColor blackColor];

mainLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin;

mainLabel.numberOfLines = 0;

//mainLabel.backgroundColor = [UIColor greenColor];

[cell.contentView addSubview:mainLabel];


photo = [[[UIImageView alloc] initWithFrame:CGRectMake(190.0,15.0,85.0,85.0)] autorelease]; 

photo.tag = PHOTO_TAG; 

photo.contentMode = UIViewContentModeScaleAspectFit;//UIViewContentModeScaleAspectFit; //


[cell.contentView addSubview:photo];


    }

else {


dateLabel = (UILabel *)[cell.contentView viewWithTag:DATELABEL_TAG];

mainLabel = (UILabel *)[cell.contentView viewWithTag:MAINLABEL_TAG];

photo = (UIImageView *)[cell.contentView viewWithTag:PHOTO_TAG];

}


NSUInteger row = [indexPath row];

NSDictionary *stream = (NSDictionary *) [dataList objectAtIndex:row];

NSString *title = [stream valueForKey:@"title"];



NSString *titleString = @"";


if( ! [title isKindOfClass:[NSString class]] )

{

titleString  = @"";

}

else 

{

titleString = title;

}


CGSize maximumSize = CGSizeMake(180, 9999);


    UIFont *dateFont = [UIFont fontWithName:@"Helvetica" size:14];

    CGSize dateStringSize = [titleString sizeWithFont:dateFont 

constrainedToSize:maximumSize 

lineBreakMode:mainLabel.lineBreakMode];


    CGRect dateFrame = CGRectMake(15.0, 28.0, 170.0, dateStringSize.height);

    mainLabel.frame = dateFrame;


mainLabel.text = titleString;

dateLabel.text = [stream valueForKey:@"created"];


NSString *i = [NSString stringWithFormat:@"http://www.website.co.uk/images/%@", [stream valueForKey:@"image"]];

NSData *imageURL = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:i]];

UIImage *newsImage = [[UIImage alloc] initWithData:imageURL];


photo.image = newsImage; 

[imageURL release];

[newsImage release];


    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-16T05:47:02+00:00Added an answer on May 16, 2026 at 5:47 am

    The problem is this:

    NSString *i = [NSString stringWithFormat:@"http://www.website.co.uk/images/%@", [stream valueForKey:@"image"]];
    
    NSData *imageURL = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:i]];
    
    UIImage *newsImage = [[UIImage alloc] initWithData:imageURL];
    

    You effectively say here, that as soon as the cell needs to be displayed, the image must be fetched and presented. This will cost some time – too much for a good user experience.

    You should fetch the images before or while you present the table view, and cache them, e.g. in an array. Or you must handle things asynchronously, meaning that you do the loading in the background, and not wait with return cell; until the image is actually downloaded. This will be a little harder to get right.

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

Sidebar

Related Questions

I have an array of values which is almost, but not quite sorted, with
Almost solved this, but it seems I'm not allowed to match with variables inside
Is it true that Map/Reduce results can be stored permanently, but not sorted? For
Almost every Express app I see has an app.use statement for middleware but I
Almost every Python web framework has a simple server that runs a wsgi application
I have a GUI problem that I would like to get sorted out, but
I am currently trying to set up an nsurlconnection I almost have everything sorted
I am using a list that can be sorted in various ways, regenerating the
Possible Duplicate: Interview Q: sorting an almost sorted array (elements misplaced by no more
There are many similar questions and I almost have the solution but I have

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.