这是我目前拥有的:
NSMutableArray *images = [[NSMutableArray alloc] initWithCapacity:21];
for(int count = 1; count <= 21; count++)
{
NSString *fileName = [NSString stringWithFormat:@"dance2_%03d.jpg", count];
UIImage *frame = [UIImage imageNamed:fileName];
[images addObject:frame];
}
UIImage imageNamed导致我出现一些内存问题,我想切换到imageWithContentsOfFile。
我可以使用单个图像,但不能使用整个数组:
NSMutableArray *images = [[NSMutableArray alloc] initWithCapacity:21];
for(int count = 1; count <= 21; count++)
{
NSString *fileName = [[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"/dance2_001.jpg"];
UIImage *frame = [UIImage imageWithContentsOfFile:fileName];
[images addObject:frame];
}
任何帮助是极大的赞赏!谢谢!
最佳答案
for(int i = 1; i <= 21; i++)
{
[images addObject:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"dance2_%03d", i] ofType:@"jpg"]]];
}
关于ios - 如何将imageWithContentsOfFile用于动画中使用的图像数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7886959/