私は iPhone プログラミングの初心者です。以下のコードを使用すると、バックグラウンドでサーバーから画像をすばやく非同期に取得できます。
画像を15枚まとめてダウンロードしたい。ユーザーが下にスクロールすると、次の 15 枚の画像をダウンロードして表示できます。また、表示されなくなった画像をアンロードして削除したい。したがって、バッチで画像をダウンロードしたいのですが、1000 個の画像がある場合は、0-15、15-30、30-45 などとしてダウンロードしたいと考えています。
どうすればこれを実装できますか?
そして、LazyloadingまたはSDWebimageソースコードプロジェクトを使用して、私が言ったような画像を取得できますが、画像を3 * 3のサムネイルに表示したい(各行に3つの画像を表示したいことを意味します)どのようにすればよいか教えてください。 Androidのユニバーサルライブラリのようなライブラリが欲しい
//remote image URLs
URLs = [[NSMutableArray alloc]init];
for (NSString *path in latestiamge)
{
NSURL *URL = [NSURL URLWithString:path];
if (URL)
{
[URLs addObject:URL];
}
else
{
}
}
self.imageURLs = URLs;
UISwipeGestureRecognizer* swipeUpGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeUpFrom:)];
swipeUpGestureRecognizer.direction = UISwipeGestureRecognizerDirectionUp;
[myScrollView addGestureRecognizer:swipeUpGestureRecognizer];
float horizontal = 2.0;
float vertical = 2.0;
for(int i=0; i<[imageURLs count]; i++)
{
if((i%3) == 0 && i!=0)
{
horizontal = 5.0;
vertical = vertical + 100.0 + 5.0;
}
CGRect frame;
frame.size.width=100.0;
frame.size.height=100.0;
frame.origin.x=0;
frame.origin.y=0;
AsyncImageView *imageView = [[AsyncImageView alloc] initWithFrame:frame];
imageView.contentMode = UIViewContentModeScaleAspectFill;
imageView.clipsToBounds = YES;
imageView.tag = i;
//load the image
imageView.imageURL = [imageURLs objectAtIndex:i];
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc]
initWithTarget:self
action:@selector(actionHandleTapOnImageView:)];
imageView.userInteractionEnabled = YES;
[imageView addGestureRecognizer:singleTap];
[myScrollView addSubview:imageView];
buttonImage1 = [UIButton buttonWithType:UIButtonTypeCustom];
[buttonImage1 setFrame:CGRectMake(horizontal, vertical, 100.0, 100.0)];
[buttonImage1 setTag:i];
[buttonImage1 setImage:[idURLs objectAtIndex:i] forState:UIControlStateNormal];
[buttonImage1 setImage:[UIImage imageNamed:@"Overlay.png"] forState:UIControlStateSelected];
[myScrollView addSubview:buttonImage];
[buttonImage1 addSubview:imageView];
[myScrollView addSubview:buttonImage1];
horizontal = horizontal + 100.0 + 5.0;
}
[myScrollView setContentSize:CGSizeMake(320.0, vertical + 3900.0)];