【发布时间】:2012-11-17 21:38:09
【问题描述】:
嗯,使用 SDWeb 图像Here
这些是我的代码:
UIImageView *sellerImage = [[UIImageView alloc]init];
[sellerImage setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:productPicture]]
placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
但它总是只加载占位符图像而不是来自 URL 的图像, 我尝试使用块来确保它是否加载图像并进入成功块,这意味着 SDWebImage 可以从 URL 加载图像但它不会更改占位符图像。
这些是我尝试使用块时的代码:
[sellerImage setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:productPicture]]
placeholderImage:[UIImage imageNamed:@"placeholder.png"]
success:^(UIImage *image, BOOL cached)
{
NSLog(@"success Block");
}
failure:^(NSError *error)
{
NSLog(@"failure Block");
}];
正如我所说,它总是进入成功块,这意味着它可以从 URL 加载图像,但不会更改占位符图像。
这是我的问题的一个屏幕。
【问题讨论】:
-
查看此链接。 stackoverflow.com/questions/15701556/…>
标签: iphone objective-c ios uiimageview sdwebimage