私の Web サイトの画像にリンクされている 10 個の URL の配列があります。
非同期イメージのダウンロードと for ループに SDWebImages を使用して、URL の配列を実行しています。しかし、最初のイメージがダウンロードされる前に、コードは For ループを介して実行されます。したがって、残りの画像はダウンロードされず、新しいビュー コントローラーは表示されません。
コードを for ループで実行できるようにするにはどうすればよいですか。画像がダウンロードされると、View Controller がポップアップし、新しい画像がダウンロードされるたびに更新されます。
これが私のコードです:
NewViewController *vc = [[NewViewController alloc] initWithNibName:nil bundle:nil];
NavigationController *navigationController = [[NavigationController alloc] initWithRootViewController:vc];
for (NSString *url in urls) {
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectZero];
[imageView setImageWithURL:[NSURL URLWithString:url]
placeholderImage:[UIImage imageNamed:@"post-imagePlaceholder"]
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {
item.image = image;
[self.images addObject:item];
vc.results = self.images;
;
}
}];
}
[self presentViewController:navigationController animated:YES completion:nil]