【问题标题】:iOS. Empty image sets in before the image completely downloaded while starting appIOS。在启动应用程序时完全下载图像之前设置空图像
【发布时间】:2012-04-20 01:00:10
【问题描述】:

我的应用程序在启动时会显示照片提要,就像 Instagram 一样。 我的问题是应用程序在完全下载之前显示空图像(用于单元格)属性。

当我向下滚动视图并再次向上滚动(使某些单元格不可见,然后通过滚动使其可见)时,单元格图像就会显示出来!

设置单元格的方法是这样的..

- (AQGridViewCell *)gridView: (AQGridView *)aGridView cellForItemAtIndex: (NSUInteger)index {
    static NSString *PlainCellIdentifier = @"PlainCellIdentifier";

    GridViewCell *cell = (GridViewCell *)[aGridView dequeueReusableCellWithIdentifier:@"PlainCellIdentifier"];

    if ( cell == nil ) {
        cell = [[GridViewCell alloc] initWithFrame: CGRectMake(0, 0, 74, 74)
                                   reuseIdentifier: PlainCellIdentifier];
    }


    [cell.captionLabel setText:text];

    [cell.imageView setImage:image];

    return cell;
}

[setImage:] 方法等待图片完成,或显示正在下载的图片,或自动重新加载,我该怎么办?

【问题讨论】:

标签: iphone xcode download uiimage reload


【解决方案1】:

你可以使用SDWebImage

网页图片 该库为 UIImageVIew 提供了一个类别,支持来自网络的远程图像。

它提供:

向 Cocoa Touch 框架添加 Web 图像和缓存管理的 UIImageView 类别 一个异步图片下载器 具有自动缓存过期处理的异步内存 + 磁盘映像缓存 保证不会多次下载相同的 URL 保证不会一次又一次地重试虚假 URL 表演!

【讨论】:

    猜你喜欢
    • 2015-03-26
    • 2014-08-07
    • 1970-01-01
    • 1970-01-01
    • 2011-09-28
    • 2021-05-28
    • 2012-03-02
    • 1970-01-01
    • 2012-12-27
    相关资源
    最近更新 更多