合适的人,我在SKScene中使用以下代码在SKScene中滚动视图 -
for (int i=0; i<[listOfImages count]; i++) {
NSDictionary *myDic = [listOfImages objectAtIndex:i];
NSString *urlImage = [myDic objectForKey:@"product_image"];
NSURL *imageURL = [NSURL URLWithString:urlImage];
NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
UIImage *cacheImage = [UIImage imageWithData:imageData];
UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/4+leftMargin, 0, cacheImage.size.width/2, cacheImage.size.height/2)];
[image setImage:cacheImage];
image.tag = tag;
image.contentMode = UIViewContentModeScaleAspectFit;
[scrollView addSubview:image];
UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
recognizer.numberOfTapsRequired = 1;
recognizer.numberOfTouchesRequired = 1;
recognizer.delegate = self;
[image addGestureRecognizer:recognizer];
[image setUserInteractionEnabled:YES];
leftMargin += SCREEN_WIDTH;
tagValue += 1;
tag += 1;
}
我需要了解如何在后台加载图像,因为有近140张图像需要加载,并且花费5分钟来加载所有内容并显示。请帮帮我!!
答案 0 :(得分:1)
你可以有一个队列,其中一个负载结束触发另一个,而不是一次触发所有负载。
我进行了谷歌搜索,如果您在应用这个概念时需要帮助,那就得到这个:
http://khanlou.com/2012/08/asynchronous-downloaded-images-with-caching/