简体   繁体   中英

UITableViewCell imageView images loading small even when they are the correct size!

Im having an issue whilst loading images into a UITableViewCell after an asynchronous download and placement into an UIImage variable..

The images appear smaller than they actually are! But when scrolled down and scrolled back up to the image, or the whole table is reloaded, they appear at the correct size...

Here is a code excerpt...

    - (void)reviewImageDidLoad:(NSIndexPath *)indexPath
{
 ThumbDownloader *thumbDownloader = [imageDownloadsInProgress objectForKey:indexPath];

    if (thumbDownloader != nil)
    {
        UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:thumbDownloader.indexPathInTableView];

  [UIView beginAnimations:nil context:nil];
  [UIView setAnimationDuration:0.4];
  [self.tableView cellForRowAtIndexPath:indexPath].imageView.alpha = 0.0;
  [UIView commitAnimations];

        cell.imageView.image = thumbDownloader.review.thumb;

  [UIView beginAnimations:nil context:nil];
  [UIView setAnimationDuration:0.4];
  [self.tableView cellForRowAtIndexPath:indexPath].imageView.alpha = 1.0;
  [UIView commitAnimations];
 }

}

Here is an image of the app just after calling this method..

http://www.flickr.com/photos/arbarlow/5288563627/

After calling tableView reloadData or scrolling around the appear correctly, go the the next flickr image, to see the normal result, but im sure you can guess that..

Does anyone have an ideas as to make the images appear correctly? im absolutely stumped?!

Regards, Alex iPhone noob

I don't think calling cellForRowAtIndexPath will necessarily return the cell that's actively being displayed (at least not deliberately). Instead you should try

    [tableView beginUpdates];
    [tableView reloadRowsAtIndexPaths:...];
    [tableView endUpdates];

and change you implementation of cellForRowAtIndexPath to update your image, set your animations etc...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM