【问题标题】:AQGridview - Loading images from web (URL)AQGridview - 从网络加载图像(URL)
【发布时间】:2011-07-04 10:33:40
【问题描述】:

我是 iPad 开发的新手。我正在使用 AQGridView 构建我的第一个 ipad 应用程序。使用以下代码,我试图将来自 Web URL 的图像加载到网格的每个单元格中,但是当我向下滚动并返回时,图像与它们应该的不同,因此它们重新加载以显示好的图像。

这是我用来加载图片的代码。

dispatch_async(dispatch_get_global_queue(0, 0), ^{
    UIImage *img = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imgPath]]];

    dispatch_async(dispatch_get_main_queue(), ^{
        _imageView.image = img;
        [self setNeedsLayout];
    });
});

我认为问题出在此处,调用 dispatch_get_main_queue() 时。但我不知道如何解决这个问题。如果有人有一个想法,它肯定会帮助我!

提前非常感谢!

问候,

【问题讨论】:

    标签: image ipad loading aqgridview


    【解决方案1】:

    Apple 在LazyTableImages 中有一个针对这个问题的干净解决方案的演示

    【讨论】:

      猜你喜欢
      • 2014-12-26
      • 2021-08-17
      • 2023-03-30
      • 1970-01-01
      • 1970-01-01
      • 2012-05-29
      • 2016-04-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多