UITableViewCell imageView图像加载小,即使它们是正确的大小!

时间:2010-12-24 23:46:40

标签: iphone objective-c uitableview ios

我在异步下载并放入UIImage变量后将图像加载到UITableViewCell时遇到问题。

图像看起来比实际小!但是当向下滚动并向上滚动到图像,或者整个表重新加载时,它们会以正确的大小显示...

这是一段代码摘录......

    - (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];
 }

}

以下是调用此方法后应用程序的图像..

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

在调用tableView reloadData或滚动显示正确后,转到下一个flickr图像,查看正常结果,但我相信你可以猜到..

有没有人有想法使图像正确显示?我绝对难倒?!

此致 亚历克斯 iPhone菜鸟

1 个答案:

答案 0 :(得分:0)

我认为调用cellForRowAtIndexPath不一定会返回正在显示的单元格(至少不是故意的)。相反,你应该尝试

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

并更改cellForRowAtIndexPath的实现以更新图像,设置动画等...

相关问题