0

私は持っていUICollectionViewます。オブジェクトごとに 2 つのスナップショットを生成したいと考えています。

サンプルコード:

        for (int index = 0; index < 2; index++) {

            UIView *dummyView = [[UIView alloc] init];
            dummyView.frame = some frame....,
            dummyView.backgroundColor = [UIColor yellowColor];
            UIGraphicsBeginImageContextWithOptions(dummyView.bounds.size, NO, [UIScreen mainScreen].scale);
            [dummyView.layer renderInContext:UIGraphicsGetCurrentContext()];
            UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext();
            UIGraphicsEndImageContext();
            NSData *imgData= UIImageJPEGRepresentation(outputImage, 1.00f);
            //Write file.
        }

cellForItemAtIndexPath にコードを記述しました。パスに画像がない場合は、自動的に作成されます。アプリケーションを初めて起動すると、多くのスナップショットが作成されているため、UI が応答しません。これにより、ユーザーの操作が遅くなります。これに対する回避策はありますか?

4

1 に答える 1