当前面临崩溃问题时,如何在不消耗大量内存(或有效地)的情况下在iOS中制作动画?
对于单个动画,我有一个100个图像的序列,每个图像约为40kb;就像有大约7个动画,合计将近700个图像。
例如,在这里我展示了一个带有2张图像的动画示例。这是我当前执行动画的代码。
/*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];
任何人都可以提出代码方面的任何改进建议,以便动画可以高效完成,或者是否有其他替代方案(如openGL或Core Animation),如果有人可以提出示例代码,则可以这样做。
ibeautiful
元芳怎么了