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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:21:41+00:00 2026-06-02T18:21:41+00:00

When the callback block for loadImage is run below, the table cell may have

  • 0

When the callback block for loadImage is run below, the table cell may have since been reused. So the image is applied to “imageView” is not relevant to this reused cell, it’s the image for the old cell.

If I make the identifier unique for each cell that has an image, the problem goes away. But this gives poor performance with many results.

Can I somehow use the same reuse identifier with a callback block and have the images turn up in the correct cells?

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

    NSDictionary *place;
    PlaceTableViewCell *cell; // UITableViewCell subclass
    NSString *identifier = @"PlaceTableViewCell";

    if (cell == nil) {

        NSArray *objects;

        objects = [[NSBundle mainBundle] loadNibNamed:@"PlaceTableViewCell" owner:self options:nil];

        for(id object in objects) {

            if([object isKindOfClass:[PlaceTableViewCell class]]) {                
                cell = (PlaceTableViewCell *)object;                
                break;
            }
        }
    }

    UIImageView *imageView;
    if((imageView = (UIImageView*)[cell viewWithTag:1])) {

        NSString *filename;
        int placeImageId = 0;
        place = [places objectAtIndex:indexPath.row];

        if(place) {

            placeImageId = [[d objectForKey:@"placeImageId"] intValue];

            if(placeImageId) {

                [[RestAPIConnector sharedInstance] loadImage :placeImageId :@"thumb" :^(NSString *response){

                    NSDictionary *image = [response JSONValue];

                    if ([image objectForKey:@"img"]) {

                        NSString *b64Img = [image objectForKey:@"img"];
                        UIImage *ui = [UIImage imageWithData:[Base64 decode:b64Img]];

                        imageView.image = ui;
                    }
                }];            
            }
        }
    }

    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-06-02T18:21:43+00:00Added an answer on June 2, 2026 at 6:21 pm

    here is what I’m doing.

    instead of using the cell directly, I’m passing in the index path

    if(user.profileImage == nil)
    {
        if (self.tableView.dragging == NO && self.tableView.decelerating == NO) {
            NSLog(@"file for user %d doesn't exist", [user.userId intValue]);
            [self startUserProfileImageDownload:user forIndexPath:indexPath];
        }
    }
    else
    {
        cell.profileImageView.image = user.profileImage;
    
    }
    

    once the download is complete, use the index path to retrieve the cell, and update the image

    MessageCell *cell = (MessageCell *)[self.tableView cellForRowAtIndexPath:path];
    
    // Display the newly loaded image
    cell.profileImageView.image = user.profileImage;
    CALayer *roundedLayer = [cell.profileImageView layer];
    

    MessageCell is my custom cell. if you don’t have use customer cell, you can use Tag to retrieve the imageView back.

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

Sidebar

Related Questions

I have a javascript/jQuery block as a callback after $.get function: function myCallBack(data, textStatus)
Inside the callback of a $.getJSON call, I have the code outlined below. The
I'm writing some callback implementation in C++. I have an abstract callback class, let's
I have this static callback function in MyClass, and I try to call another
How should I use callback functions in parsekit? suppose I have the following rule:
I have a list of callback functions that I need to invoke when an
In the below code block I need to make sure initialize1 and initialize2 calls
Assume I have method void SomeMethod(Action callback) This method does some work in background
I have a JSP page that renders a block of HTML. In normal usage,
I am trying to push a view controller from inside a callback block. The

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.