我正在使用AFNetworking
类别UIImageView+AFNetworking.h
从 S3 下载图像。我得到一个预签名的 URLRequest 并继续获取图像。这是在一个仅用于显示照片的控制器中:
- (void)viewWillAppear:(BOOL)animated
{
NSURLRequest *request = [BFAWSUploader downloadPhotoWithFileName:[NSString stringWithFormat:@"%@.jpg", _topicMessage.attachment_s3_name]];
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
[_imageView setImageWithURLRequest:request placeholderImage:[UIImage imageNamed:@"Default.png"] success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
NSLog(@"Pulled down image successfully");
[hud hide:YES];
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
NSLog(@"Failed to pull down image");
}];
}
我看到日志条目“成功下拉图像”,但之后我没有看到图像视图更新。相反,我必须离开视图控制器,然后再返回,我会看到缓存的条目。