![](/img/trans.png)
[英]IOS using SDWebImage gives no setImageWithURL method error
[英]Wait till setImageWithURL is loaded SDWebImage
我需要的是等到setImageWithURL
完成處理圖像后,這是我在viewDidLoad方法上的代碼:
UIImageView *test = [[UIImageView alloc] init];
[test setImageWithURL:[NSURL URLWithString:object.imageUrl]];
無論如何,是否可以將此方法設置為同步運行? 我已經嘗試了completed
塊,但是由於某些奇怪的原因,它從未被調用。
據我所記得,SDWebImage沒有同步下載/設置圖像的方法(出於明顯的原因)。 但是,如果您的用例希望您使用同步方法,請嘗試以下操作:
UIImageView *test = [[UIImageView alloc] init];
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:imageURL]];
[test setImage:image];
希望這可以幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.