サーバからの画像を含むUIScrollViewがあります。UIScrollView内で画像を読み込む際のアクティビティインジケータ
イメージがロードされている間にアクティビティインジケータを配置する必要があります。
UIScrollViewには、サーバーからの動的なイメージが含まれています。
画像が読み込まれている間に各ページにアクティビティインジケータを追加し、画像が読み込まれたら削除するにはどうすればよいでしょうか。
は、ここで画像を取得するために私のコードです:
NSDictionary *items = [NSDictionary dictionaryWithObject:dictInfo forKey:@"images"];
imageList = [items objectForKey:@"images"];
NSArray *img = [imageList objectForKey:@"list"];
NSInteger imgCount = [img count];
buttonArray = [[NSMutableArray alloc] init];
for (int i=0; i<imgCount; i++) {
NSDictionary *imgDict = [img objectAtIndex:i];
// REQUEST FOR IMAGES
NSString *imgPath = [imgDict objectForKey:@"image_slot"];
NSString *imgURL = imgPath;
__block ASIHTTPRequest *requestImage = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:imgURL]];
[requestImage setCompletionBlock:^{
imgView = [UIImage imageWithData:[requestImage responseData]];
if (imgURL.length) {
[pendingRequests removeObjectForKey:imgURL];
}
scrollView.userInteractionEnabled = YES;
scrollView.exclusiveTouch = YES;
scrollView.canCancelContentTouches = YES;
scrollView.delaysContentTouches = YES;
scrollView.bounces = NO;
CGRect frame;
frame.origin.x = self.scrollView.frame.size.width * i;
frame.origin.y = 0;
frame.size = self.scrollView.frame.size;
SWTUIButton *imgBtn = [[SWTUIButton alloc] initWithFrame:frame];
imgBtn.url = [requestImage.userInfo objectForKey:@"rURL"];
[imgBtn setImage:imgView forState:UIControlStateNormal];
imgBtn.backgroundColor = [UIColor clearColor];
[imgBtn addTarget:self action:@selector(buttonpushed:) forControlEvents:UIControlEventTouchUpInside];
[scrollView addSubview:imgBtn];
[buttonArray addObject:imgBtn];
[imgBtn release];
self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * img.count, self.scrollView.frame.size.height);
}];
私が代わりに何をしたか .. ..私が言ったプロジェクトを使用して苦労してる私は、IOSの開発にちょうど新しいです.. を返信いただきありがとうございます、私はのためのプロパティ(UIActivityIndicatorView)を作成していますボタン。アクティビティインジケータが表示され、イメージが読み込まれるとアニメーションが停止します。 – lee