aBtnとbBtnという 2 つのメインの小さな画像ボタンがあります。aBtn/bBtnをクリックすると、デフォルトで 6 つの画像 URL が生成され、画像が nil でないことを確認します。6つの画像で、一部の画像が空の場合、その空の画像だけを避け、それに応じてフレームを設定します。aBtn からbBtn をクリックすると、時間の遅延があります。これは、毎回 nil/empty 画像なしで生成される 6 つの URL 画像をチェックし、それに応じてフレーム位置を設定することによるものです。
これは、画像を表示するために使用したコードです。6つのURL画像データからの状態を確認すると、3番目のURL画像がnilであると言われた場合、データはnilではありません。画像を表示するための遅延を克服するにはどうすればよいですか?
NSMutableString *strUrl;
int i;
int j=7;
int k=0;
xorigin=350;
int cou=1;
for( i=1;i<j;i++){
strUrl=[[NSMutableString alloc]init];
UIImageView *imageView= [[UIImageView alloc]init];
[strUrl appendFormat:@"http://commondatastorage.googleapis.com/images2.solestruck.com/%@%@%@%@%@%@%@)-01060%d.jpg",
[[[[shoeDetailDict objectForKey:@"vendorName"] lowercaseString] lowercaseString] stringByReplacingOccurrencesOfString:@" " withString:@"-"],@"-shoes/",[[shoeDetailDict objectForKey:@"vendorName"] stringByReplacingOccurrencesOfString:@" " withString:@"-"],@"-shoes-",[[shoeDetailDict objectForKey:@"productName"] stringByReplacingOccurrencesOfString:@" " withString:@"-"],@"-(",[[prdcolorimgArray objectAtIndex:tagedColor] stringByReplacingOccurrencesOfString:@" " withString:@"-"],i];
NSURL *imageUrl=[[NSURL alloc]initWithString:strUrl];
NSError *error;
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:strUrl] options:NSDataReadingUncached error:&error];
NSLog(@"imageurl colors : %@",strUrl);
if(i==4){
imageView.frame =CGRectMake(25, 0, (self.view.frame.size.width*80)/100,(self.view.frame.size.height*40)/100);
[imageView setImageWithURL:imageUrl];
}
else{
if(data != nil ){
cou++;
imageView.frame =CGRectMake(xorigin, 0, (self.view.frame.size.width*80)/100,(self.view.frame.size.height*40)/100);
[imageView setImageWithURL:imageUrl];
xorigin=xorigin+320;
}
}
imageView.backgroundColor=[UIColor whiteColor];
[productScroll addSubview:imageView];
productScroll.contentSize = CGSizeMake((self.view.frame.size.width)*cou, (self.view.frame.size.height*40)/100);
productScroll.contentOffset=CGPointMake(0, 0);
k++;
}