Iphone 检查图像是否已缓存
我有这个方法,当点击单元格时,可以下载Iphone 检查图像是否已缓存,iphone,ios,ipad,caching,afnetworking,Iphone,Ios,Ipad,Caching,Afnetworking,我有这个方法,当点击单元格时,可以下载UIImageView的全尺寸图像 - (void)configureView { NSURLRequest *URLRequest = [[NSURLRequest alloc] initWithURL:self.imageURL]; AFImageRequestOperation *operation = [[AFImageRequestOperation alloc] initWithRequest:URLRequest];
UIImageView
的全尺寸图像
- (void)configureView
{
NSURLRequest *URLRequest = [[NSURLRequest alloc] initWithURL:self.imageURL];
AFImageRequestOperation *operation = [[AFImageRequestOperation alloc] initWithRequest:URLRequest];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
[SVProgressHUD showSuccessWithStatus:@"Done!"];
[self.imageView setImage:responseObject];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
[operation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {
float percentage = (totalBytesRead / (totalBytesExpectedToRead * 1.0f) * 100);
NSLog(@"Percentage: %f", percentage);
if (percentage != 100.0)
{
[SVProgressHUD showWithStatus:[NSString stringWithFormat:@"Downloading... %0.0f%%", percentage]];
}
}];
[operation start];
}
因此,下载完成后,[SVProgressHUD showSuccessWithStatus:@“完成!”代码>被调用。
但是,当您返回到tableViewController
并单击同一单元格时,[SVProgressHUD showSuccessWithStatus:@“完成!”即使缓存了图像,也会再次调用code>。
如何检查映像是否已缓存,并且仅调用[SVProgressHUD showSuccessWithStatus:@“完成!”代码>当它不是时?AFImageRequestOperation不会缓存图像。我认为您将AFNetworking的类别“UIImageView+AFNetworking”与“AFImageRequestOperation”混淆了。类别不缓存图像,而AFImageRequestOperation不缓存图像。AFImageRequestOperation不缓存图像。我认为您将AFNetworking的类别“UIImageView+AFNetworking”与“AFImageRequestOperation”混淆了。类别不缓存图像,AFImageRequestOperation不缓存图像。当我打开同一单元格时,imageView已加载下载的图像,这是为什么?当我关闭并打开应用程序并打开单元格时,图像未下载,当我打开imageView已加载下载图像的同一单元格时,为什么?当我关闭并打开应用程序并打开手机时,图像并没有被下载,而是在那里