I posted another question similar. This is my old code as some ppl say it would be even better, but there i didnt found a solution to release the allocated memory.
imageArray_danceright = [[NSArray alloc] initWithObjects:
[UIImage imageNamed:@"FrankieDanceRetime_0001.jpg"],
.. 40 images
[UIImage imageNamed:@"FrankieDanceRetime_00040.jpg"],nil];
imageArray_danceleft = [[NSArray alloc] initWithObjects:
[UIImage imageNamed:@"FrankieDanceRetime_0041.jpg"],
.. 40 images
[UIImage imageNamed:@"FrankieDanceRetime_00080.jpg"],nil];
imageArray_stand= [[NSArray alloc] initWithObjects:
[UIImage imageNamed:@"FrankieSingtRetime_0001.jpg"],
[UIImage imageNamed:@"FrankieSingtRetime_0002.jpg"],
[UIImage imageNamed:@"FrankieSingtRetime_0003.jpg"],nil];
//start animation
myimageview.animationImages = imageArray_stand;
myimageview.animationDuration = 0.23;
myimageview.contentMode = UIViewContentModeBottomLeft;
myimageview.animationRepeatCount = 0.0;
myimageview.image = [myimageview.animationImages objectAtIndex:1];
[myimageview startAnimating];
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
touch = [[event allTouches] anyObject];
if ([touch view] == overlay_fuesserechts) {
[myimageview setAnimationImages:imageArray_danceright];
myimageview.animationDuration = 2.0;
myimageview.contentMode = UIViewContentModeBottomLeft;
myimageview.animationRepeatCount = 1;
[myimageview startAnimating];
}
if ([touch view] == overlay_fuesselinks) {
[myimageview setAnimationImages:imageArray_danceleft];
myimageview.animationDuration = 2.0;
myimageview.contentMode = UIViewContentModeBottomLeft;
myimageview.animationRepeatCount = 1;
[myimageview startAnimating];
}
Its works fine.. just when i look in Instrument/Allocation, it does not release the memory. It starts with 8mb for the 'stand' anim, goes up to 32mb for fuesserechts and when i click fuesselinks it goes up to 55mb (i have 6 more anim.. so a few more and it just crash) When I do set [myimageview setAnimationImages:nil]; (in touchesBegan) for each setAnimationImages ... i still does not release the Memory. All Allocatoins Overall bytes, still increase. When I do set [myimageview.animationImages release]; in (touchesbegan) for each setAnimationImages... it even crash after a few touches.
Thanks Chris