【发布时间】:2012-07-05 12:52:01
【问题描述】:
我正在 iPad 上开发一个只有动画的应用程序。我正在使用大约 400 张 JPEG 图像来制作动画。大小对应于 7MB。但是动画在 50 幅图像后停止并且应用程序崩溃。我在 NIB 中使用 UIImageView 作为 IBOutlet 并使用 NSTimer 更改代码中的图像。应用程序崩溃并显示消息已收到内存警告。我使用 Instruments 工具检查过,没有发现任何泄漏。
欢迎提出任何建议。
代码
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self callTimer];
}
-(void) callTimer
{
tempView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 768, 1024)];
[self.view addSubview:tempView];
animationTimer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(animateCharacter) userInfo:nil repeats:YES];
}
-(void) animateCharacter
{
imageNumber++;
if(imageNumber <= 400)
{
tempView.image = [UIImage imageNamed:[NSString stringWithFormat:@"body%d.jpg",imageNumber]];
}
else
{
//tempView.image = [UIImage imageNamed:[NSString stringWithFormat:@"pose.png",imageNumber]];
imageNumber = 0;
tempImageNumber = 0;
[tempView removeFromSuperview];
[tempView release];
tempView = nil;
[animationTimer invalidate];
animationTimer = nil;
}
}
【问题讨论】:
-
这意味着您可以添加无限时间的图像视图,以便问题出现您只需将图像更改为图像视图。这样你的问题就可以解决了
标签: iphone ios memory warnings