我想異步下載多個圖像。我有10個圖像陣列,我想在10 uiimageview
,我做這樣的顯示這些圖片,但只顯示一個圖像
- (void)loadImage {
NSData* imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:[myarray objectatindex:0]]];
UIImage* image = [[[UIImage alloc] initWithData:imageData] autorelease];
[imageData release];
[self performSelectorOnMainThread:@selector(displayImage:) withObject:image waitUntilDone:NO];
}
The final method we need to create takes in the image to display and sets it on our image view.
- (void)displayImage:(UIImage *)image {
[imageView setImage:image]; //UIImageView
}
所以,請你告訴我,我怎麼能顯示不同的多張圖片,而無需創建10不同的方法。
是的,這可能是最好的辦法,作爲替代方案,你可以使用SDWebImage,你可以找到https://github.com/rs/SDWebImage – mohacs
我將如何使用該類 –
@Adnan哪一個? –