gpt4 book ai didi

iphone - AFNetworking:setImageWithURLRequest 未设置图像

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:56:32 25 4
gpt4 key购买 nike

我尝试在 tableViewCell 上使用 AFNetworking 的 setImageWithURLRequestImageView 上设置图像。如果我不在方法中包含 successfailure block ,如下所示:

[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");
}];

}

最佳答案

来自UIImageView+AFNetworking.h:

If a success block is specified, it is the responsibility of the block to set the image of the image view before returning.

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

[cell.thumbnailImageView setImage: image]

关于iphone - AFNetworking:setImageWithURLRequest 未设置图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14718634/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com