0

画像をプリロードするためにフラッディングコードを使用します。

NSMutableArray *test_loose_preload = [[NSMutableArray alloc] initWithCapacity:test_loose_array.count];

for (int aniCount = 0; aniCount < test_loose_array.count; aniCount++) {

    UIImage *frameImage = [test_loose_array objectAtIndex:aniCount];
    UIGraphicsBeginImageContext(frameImage.size);
    CGRect rect = CGRectMake(0, 0, frameImage.size.width, frameImage.size.height);
    [frameImage drawInRect:rect];
    UIImage *renderedImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    [test_loose_preload addObject:renderedImage];

}

test_loose = test_loose_preload;

このブロック内で、画像がすでにプリロードされていて、これ以上プリロードする必要がないかどうかを確認する可能性はありますか?

アイデアをありがとう!

4

2 に答える 2

0

オフトピック:

あなたはfor eachループを使うことができます

for (UIImage *frameImage in test_loose_array) {

  UIGraphicsBeginImageContext(frameImage.size);
  ...
  [test_loose_preload addObject:renderedImage];
}
于 2012-11-16T15:40:11.763 に答える
0

おそらく私は質問を誤解していますが、画像をビルドしてtest_loose_preload配列に詰め込んだ場合、画像は「プリロード」されているように見えます。配列を通過する前に、他のスレッドが同じ作業を行う可能性があることを懸念していると思います。

その場合は、[test_loose_preload objectAtIndex:aniCount]をチェックするだけでこれをチェックでき、その結果がnilでない場合は、その結果をスキップして次のインデックスに進みます。

于 2012-11-16T15:44:52.193 に答える