Reputation: 345
I'm working on an application, where I use animations. To animate my images, I use some NSArray
:
@property (retain) NSArray * imagePig1;
When I open the UIViewController
for the first time, it works. If I open it a second time with the previous which open it, it works, but when I open once and re-open with another ViewController
, it crashes and gives me an error like this :
As you could see, I make this sort of code to animate my UIImageView
:
-(void) AllocPigWithImage:(UIImageView *)ImagePig
{
[ImagePig stopAnimating];
[ImagePig setAnimationImages:_imagePig1];
[ImagePig setAnimationRepeatCount:INFINITY];
[ImagePig setAnimationDuration:(1/7)];
[ImagePig startAnimating];
}
How to fix it please ?
Thanks !
EDIT : This is what i'm having when I step over all those breakpoints : crash. But don't know how to see what array is failing :/
Upvotes: 0
Views: 459
Reputation: 5268
I referred images as
self.imagePig1 = [NSArray arrayWithObjects:[UIImage imageNamed:@"imgres.jpeg"]
,[UIImage imageNamed:@"images.jpg"], nil];
and used your method
-(void) AllocPigWithImage:(UIImageView *)ImagePig
{
[ImagePig stopAnimating];
[ImagePig setAnimationImages:_imagePig1];
[ImagePig setAnimationRepeatCount:INFINITY];
[ImagePig setAnimationDuration:(1/7)];
[ImagePig startAnimating];
}
which is not crashing for me . Please cross check your array allocation code . It must look like if you NSLog
2013-07-04 18:56:04.324 imageTest[9330:c07] (
"<UIImage: 0x7178520>",
"<UIImage: 0x71771d0>"
)
Upvotes: 1