指定されたコードを使用して、それぞれの URL から画像をダウンロードしていますが、問題が原因で機能せず、問題を診断できません。この問題を解決してください。前もって感謝します。
-(void)createScrollViewControls
{
[self removeAllControlsFromScrollView];
totalNumberOfImages=[arrImages count];
__block int x=0;
__block int y=0;
__block int scroll=0;
__block UIImage *tempimag=nil;
if(totalNumberOfImages>0) //If product images are there
{
// imageScroll.contentSize=CGSizeMake(imageScroll.frame.size.width*totalNumberOfImages, IMAGEHEIGHT);
for(int i=0;i<totalNumberOfImages;i++){
NSLog(@"Value=%@",arrImages);
UIActivityIndicatorView *activity= [[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(77+scroll, 38, 30, 30)];
[activity setBackgroundColor:[UIColor clearColor]];
[activity setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleGray];
[imageScroll addSubview:activity];
[activity startAnimating];
dispatch_queue_t concurrentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(concurrentQueue, ^{
NSURL *imageURL=[NSURL URLWithString:[arrImages objectAtIndex:i]];
NSData *tempData=[NSData dataWithContentsOfURL:imageURL];
UIImage *tImage=[UIImage imageWithData:tempData];
if (tImage==nil)
{
tImage=[UIImage imageNamed:@"NoImage.png"];
}
dispatch_async(dispatch_get_main_queue(), ^{
tempimag= tImage;
UIImageView *imageView=[[UIImageView alloc] initWithFrame:CGRectMake(x, y, IMAGEWIDTH, IMAGEHEIGHT)];
//if url is there but image not getting downloaded then show a static image
if (!tempimag)
{
imageScroll.contentSize=CGSizeMake(imageView.frame.size.width, IMAGEHEIGHT);
NSLog(@"no underlying data");
imageView.image = [UIImage imageNamed:kNoImageAvailable];
[imageScroll addSubview:imageView];
// totalNumberOfImages = 0;
}
else{
[activity stopAnimating];
imageScroll.contentSize=CGSizeMake(imageScroll.frame.size.width*totalNumberOfImages, IMAGEHEIGHT);
imageView.image=tempimag;
[imageScroll addSubview:imageView];
x=x+imageScroll.frame.size.width;
}
});
});
/*
UIImageView *imageView=[[UIImageView alloc] initWithFrame:CGRectMake(x, y, IMAGEWIDTH, IMAGEHEIGHT)];
if (!tempimag)//if url is there but image not getting downloaded then show a static image
{
imageScroll.contentSize=CGSizeMake(imageView.frame.size.width, IMAGEHEIGHT);
NSLog(@"no underlying data");
imageView.image = [UIImage imageNamed:kNoImageAvailable];
[imageScroll addSubview:imageView];
totalNumberOfImages = 0;
break;
}
else{
imageScroll.contentSize=CGSizeMake(imageScroll.frame.size.width*totalNumberOfImages, IMAGEHEIGHT);
imageView.image=tempimag;
[imageScroll addSubview:imageView];
x=x+imageScroll.frame.size.width;
}
} */
scroll+=184;
}
}