我想异步下载多个图像。我有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哪一个? –