Note that there are some explanatory texts on larger screens.

plurals
  1. POUITableview dequeueReusableCellWithIdentifier and UIImageView issue?
    primarykey
    data
    text
    <p>I'm loading asynchronously images into UITableView and each row has different image. the problem is when i scroll the UITableView the previous images are loaded again in the new rows and after a while these images are changed to the correct ones (this problem is gone when i removed <strong>dequeueReusableCellWithIdentifier</strong> but it reduces the performance)</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; if(cell == nil) { NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomCellFriends" owner:self options:nil]; cell = [nibObjects objectAtIndex:0]; nibObjects = nil; } UIImageView *avatar = (UIImageView *)[cell viewWithTag:100]; UILabel *name = (UILabel *)[cell viewWithTag:2]; UILabel *city = (UILabel *)[cell viewWithTag:3]; EntryProfile *entryForRow = [entriesProfileArray objectAtIndex:indexPath.row]; avatar.image = nil; NSString *strLinkImage = [entryForRow.apiAvatarPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSArray *args = [NSArray arrayWithObjects:avatar,strLinkImage,[NSString stringWithFormat:@"%d",indexPath.row], nil]; NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(addPhotoWithImageView:) object:args]; [operationQueue addOperation:operation]; [operation release]; // Set the name of the user name.text = entryForRow.name; return cell; } // Method - (void)addPhotoWithImageView:(NSArray *)args { UIImageView *imageView = (UIImageView *)[args objectAtIndex:0]; NSString *strLinkImage = (NSString *)[args objectAtIndex:1]; NSString *index = (NSString *)[args objectAtIndex:2]; NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.example.com%@",strLinkImage]]]; UIImage *imageField = [[UIImage alloc] initWithData:imageData]; if (imageData) { [imageView performSelectorOnMainThread:@selector(setImage:) withObject:imageField waitUntilDone:NO]; } [imageField release]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload