gpt4 book ai didi

ios - 图像未加载图像

转载 作者:行者123 更新时间:2023-11-29 00:17:48 26 4
gpt4 key购买 nike

我只想为UIButton设置图像并为其创建一个IBOutlet。我在它上面有一个加载程序,当加载图像时,加载程序将停止并为该按钮分配一个新图像。调用代码时,占位符图像将保留,并且 url 图像不会加载

  [_Image1 sd_setBackgroundImageWithURL:[NSURL URLWithString:[arrayGallery valueForKey:@"link"][0]] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"blurred-background"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
[_ImageLoader1 stopAnimating];
[_ImageLoader1 removeFromSuperview];
}];

最佳答案

您正在使用完成 block 从 url 下载图像。所以你需要按照下面的方式做。

 [_Image1 sd_setBackgroundImageWithURL:[NSURL URLWithString:[arrayGallery valueForKey:@"link"][0]] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"blurred-background"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {

[_Image1 setImage:btnImage forState:UIControlStateNormal];//Don't forgot to check for error if error is nil or image is not nil then only set image

[_ImageLoader1 stopAnimating];
[_ImageLoader1 removeFromSuperview];
}];

关于ios - 图像未加载图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44841173/

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