-1

对的家伙,我在我的 SKScene 中使用以下代码从 SKAction 运行滚动视图 -

    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 分钟来加载所有内容并显示。请帮帮我!

4

1 回答 1

1

您可以有一个队列,其中一个负载结束触发另一个负载,而不是一次触发所有负载。

如果您在应用该概念时需要帮助,我进行了谷歌搜索并得到了这个:

http://khanlou.com/2012/08/asynchronous-downloaded-images-with-caching/

于 2013-10-10T21:45:20.673 回答