我正在使用 cellForRowAtIndexPath 中的以下代码从 Web 服务中获取图像:
[cell.posterImageView setImageWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[postersURLArray objectAtIndex:indexPath.row]]] placeholderImage:[UIImage imageNamed:@"placeholder.png"]
success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image)
{
if (request)
{
[UIView transitionWithView:cell.posterImageView
duration:1.0f
options:UIViewAnimationOptionTransitionCurlUp
animations:^{[cell.posterImageView setImage:image];}
completion:nil];
posterImageView.tag = indexPath.row;
posterImageView.image = image;
[myImage insertObject:posterImageView atIndex:posterImageView.tag];
}
else
{
NSLog(@"Cached");
}
}
failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error)
{
NSLog(@"Failed to fetch poster.");
}];
但它总是会产生错误。我已经分配了 myImage 可变数组。