2012-03-13 82 views
0

我的UIImage对象的数组如下:立即初始化的UIImage

frames = [[NSMutableArray alloc] initWithCapacity:[sortedArray count]]; 
for (int nDx = 0; nDx < [sortedArray count]; nDx++) 
{ 
    NSString * sImageName = [sortedArray objectAtIndex:nDx]; 
    [frames addObject:[UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@", imageFolderPath, sImageName]]]; 
} 

在我的计时方法,我做的影像以下循环:

self.image = [frames objectAtIndex:currentFrame]; 
currentFrame++; 
if (currentFrame >= [frames count]) currentFrame = 0; 

然而,当我开始图像循环的计时器第一次减速,然后一切按预期工作。我也没有计时器尝试过。

如何预先加载图像,以便在我的计时器启动时准备好去?

感谢您的帮助。

回答

0

您可以使用this代码使用单独的线程加载图像。

如果有效,我会在这里添加它。

0

这里img_array是UIImageView的

img_array.animationImages = [NSArray arrayWithObjects: 
            [UIImage imageNamed:@"img_1.png"], 
            [UIImage imageNamed:@"img_2.png"], 
            [UIImage imageNamed:@"img_3.png"],nil]; 


[img_array.animationImages setAnimationRepeatCount:HUGE_VAL]; 
img_array.animationImages .animationDuration = 4; 
[img_array.animationImages startAnimating]; 
[self.view addSubview:img_array] 

试试这个: