2

我正在尝试在 tableViewCell上ImageView使用 AFNetworking设置图像。setImageWithURLRequest如果我没有像这样在方法中包含successandfailure块:

[cell.thumbnailImageView setImageWithURL:url placeholderImage:nil]; 

一切正常,图像设置。不幸的是我需要积木。

这是我目前拥有的cellForRowAtIndexPath

if (self.images) { //check if the array of images is set, fetched from a URL

        NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString: [[self.images objectAtIndex:indexPath.row] objectForKey:@"tbUrl"]]];

        [cell.thumbnailImageView setImageWithURLRequest:request placeholderImage:[UIImage imageNamed:@"placeholder"] success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
                NSLog(@"success"); //it always lands here! But nothing happens
        } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
                NSLog(@"fail");
        }];

    }
4

1 回答 1

10

来自UIImageView+AFNetworking.h

如果指定了成功块,则该块负责在返回之前设置图像视图的图像。

在你的成功块中,你需要说:

[cell.thumbnailImageView setImage: image]
于 2013-02-06T00:16:13.167 回答