【发布时间】:2011-12-28 02:26:08
【问题描述】:
当我目前面临崩溃问题时,如何在不消耗大量内存(或高效)的情况下在 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,如果可以的话,任何人都可以建议一个示例代码。
【问题讨论】:
标签: iphone ios crash core-animation