本地化 iOS 应用后,UIImageView 不显示下载的图像

UIImageView not show downloaded images after localized iOS app

当我本地化 iOS 应用程序时。 UIImageView 根本不显示图片,这些图片是我从 urls 下载的。 注意:我正在使用 AsyncImageView 组件。

@implementation CategoryView

+ (CategoryView *)getViewWithTitle:(NSString *)title andImageUrl:(NSString *)imgUrl {

    CategoryView *view = [[[NSBundle getBundle] loadNibNamed:@"CategoryView" owner:self options:nil] objectAtIndex:0];


    [view configureWithTitle:title andImageUrl:imgUrl];

    return view;
}

- (void)configureWithTitle:(NSString *)title andImageUrl:(NSString *)imgUrl {


    [self bringSubviewToFront:_viewBtn];

    self.imageView.layer.cornerRadius = self.imageView.frame.size.width / 2;
    self.imageView.clipsToBounds = YES;

    self.categoryTitleLabel.text = title;
    [self.imageView setImageURL:[NSURL URLWithString:imgUrl]];
}

据我所知,您想要访问从 url 下载的那些图片,每次下载完成后都会显示,对吗?

如果是这样,那么我想通知你,AsyncImageView 只会将图像异步下载到缓存中,但它不会将图像长时间存储到磁盘中,因此你无法在离线模式下将图像显示到 imageView 中,

为此,您需要将所有下载的图像保存到缓存内存中,并需要从中获取图像,

您可以使用FastImageCache

您可以尝试 SDWebImage 库,它提供了一个支持缓存的异步图像下载器。

文档中列出的一些功能:

Categories for UIImageView, UIButton, MKAnnotationView adding web image and cache management

An asynchronous image downloader

An asynchronous memory + disk image caching with automatic cache expiration handling

A background image decompression

A guarantee that the same URL won't be downloaded several times

A guarantee that bogus URLs won't be retried again and again

A guarantee that main thread will never be blocked

Performances!

Use GCD and ARC