1
我正在iphone应用程序中,我必须在点击一个按钮后从不同的文件夹中选择图像。我在用户界面上有5个UIButtons和5个图像文件夹,每个包含近100个图像。我为所有的UIButtons图像使用相同的数组。我通过下面的函数填充数组:Resolving same NSMutableArray
-(void)playAnimations:(NSString*)animationName:(int)photoCount
{
NSString *photoPathName;
UIImage *object = [[UIImage alloc]init];
for (int i=1; i<photoCount+1; i++)
{
NSString *[email protected]"";
if (i<10) {
imagesName =[photoPathName stringByAppendingFormat:@"000%d",i];
}
else if(i>9 && i<100)
imagesName =[photoPathName stringByAppendingFormat:@"00%d",i];
else if(i>99 && i<1000)
imagesName =[photoPathName stringByAppendingFormat:@"0%d",i];
object = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:imagesName ofType:@"png"]];//[UIImage imageNamed:imagesName];
[self.arrayImagesName addObject:object];
}
self.animationImage.animationImages = self.arrayImagesName;
self.animationImage.animationDuration =durationTime ;// defaults is number of animation images * 1/30th of a second
self.animationImage.animationRepeatCount = 1; // default is 0, which repeats indefinitely
[self.animationImage startAnimating];
}
我从第二次点击一次又一次让内存泄漏(它运行正确的第一次点击)以及应用变得崩溃。
我在哪里犯错?请帮助/建议我以正确的方式实施它。
谢谢。