How can i do animation in iOS with out consuming much memory(or efficiently) as i am currently facing crash problems?
For an single animation I am having a sequence of 100 images and each image is about 40kb;like that there are about 7 animations totalling almost 700 images.
For example here i have shown a sample animation with 2 images.This is my current code for doing animation.
/*First taking two images into an Array*/
NSArray *imageArray = [NSArray arrayWithObjects:[UIImage imageNamed:@"img1"],[UIImage imageNamed:@"img2"],nil];
/*Creating an image view as a layer for performing the animation */
imgView = [UIImageView alloc];
[imgView initWithFrame:CGRectMake(110,245,100,100)];
/*Setting the images for performing animations*/
imgView.animationImages = imageArray;
imgView.animationDuration = 8.5 ;//delay for performing the animation
imgView.animationRepeatCount = 1;
/* ..and finally adding the animation to the current view */
[self.view addSubview:imgView];
[imgView startAnimating];
[imgView release];
[imgView stopAnimating];
imageArray = nil;
[imageArray release];
Can anyone suggest any improvement in the code so that the animations can be efficiently done or is there any other alternative like openGL or Core Animation ,if so can anyone suggest a sample code to do so.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…