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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:14:26+00:00 2026-05-27T00:14:26+00:00

I’m building my custom cell for a table view. I’m trying to load an

  • 0

I’m building my custom cell for a table view. I’m trying to load an image from internet and for it, i’m using async download. The image is being downloaded, but it’s not showing this image in my cell. I already tried to show in a normal view and it’s working fine. It does work too if the image is already downloaded or if I roll the table view and show the cell again. Does anybody knows what’s going on?

Code:

DownloadImageManager.m

-(id)initWithImageName:(NSString *)imageAddress{
    self = [super initWithFrame:CGRectMake(10, 5, 100, 100)];
    if (self){
        self.urlString = imageAddress;
        av = [[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge] autorelease];
        av.frame = self.frame;
        [av setBackgroundColor:[UIColor greenColor]];
        [self addSubview:av];
        [av startAnimating];
        [self checkImage];
    }
    return self;
}

-(void)checkImage{
    bool isImageOnSysten = [self isImageOnFileSystem];
    if (isImageOnSysten) {
        //If image is on the system, loads the image, it's working fine here
        NSLog(@"CSantos: isImageOnSysten %@ is on system", self.urlString);
    } else {
        //here is the problem:
        [self downloadImage];
    }
}

-(void)downloadImage{
    NSURL *url = [NSURL URLWithString:self.urlString];
    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
    [request setDelegate:self];
    [request setAllowCompressedResponse:YES];
    [request setQueuePriority:NSOperationQueuePriorityLow];
    [request setDidFinishSelector:@selector(requestFinished:)];
    [request setDidFailSelector:@selector(requestFailed:)];
    [request setTimeOutSeconds:25];
    [request setNumberOfTimesToRetryOnTimeout:3];

    [request startAsynchronous];
}

- (void)requestFinished:(ASIHTTPRequest *)request
{
    NSData *responseData = [request responseData]; 
    NSArray *words = [self.urlString componentsSeparatedByString:@"/"];
    NSString *fileName = [words lastObject];
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *documentsDirectory = [paths objectAtIndex:0]; 
    NSString *writablePath = [documentsDirectory stringByAppendingPathComponent:fileName]; 
    NSError *error = nil;
    [responseData writeToFile:writablePath options:NSDataWritingAtomic error:&error];
    NSLog(@"Write returned error: %@", [error localizedDescription]);
    [av stopAnimating];
    [av removeFromSuperview];
}

CellForProgram.m

- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier]) {

        textLabel = [[UILabel alloc]initWithFrame:CGRectMake(60, 31, 235, 40)] ;
        [self.contentView addSubview:textLabel];

        photo = [[UIImageView alloc] initWithFrame:CGRectMake(5, 5, 70, 70)];
        [photo setBackgroundColor:[UIColor blueColor]];
        photo.image = imagePhoto.image;
        [self.contentView addSubview:photo];
    }
    return self

Cell Caller

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

    static NSString *CellIdentifier = @"Cell";

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

    cell.textLabel.text = [speaker objectAtIndex:indexPath.row];

    DownloadImageManager *imageManager = [[DownloadImageManager alloc] initWithImageName:[images objectAtIndex:indexPath.row]];
    [cell.photo setImage:imageManager.image];
    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-27T00:14:27+00:00Added an answer on May 27, 2026 at 12:14 am

    I told I wouldn’t need to do this kind of change on DownloadImageManager! But thanks for trying to help, it helped me in other stuff I was stucked!

    CellForProgram.m

    - (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier {
        if (self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier]) {
    
            textLabel = [[UILabel alloc]initWithFrame:CGRectMake(60, 31, 235, 40)] ;
            [self.contentView addSubview:textLabel];
    
            imagePhoto = [[DownloadImageManager alloc] initWithImageName:imageAdress.text];
            [self.contentView addSubview:imagePhoto];
        }
        return self
    }
    

    DownLoadImageManager.m: add this method

    -(void)changeImage:(NSString *)newImage{
        self.urlString = newImage;
        [self checkImage];
    }
    

    Cell Caller

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
        static NSString *CellIdentifier = @"Cell";
    
        CellForProgram *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier] ;
        if (cell == nil) {
            cell = [[[CellForProgram alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
        }
    
        cell.textLabel.text = [speaker objectAtIndex:indexPath.row];
    
        [cell.imagePhoto changeImage:[images objectAtIndex:indexPath.row]];
        return cell;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
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
Basically, what I'm trying to create is a page of div tags, each has
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.