【发布时间】:2011-06-12 09:14:23
【问题描述】:
我的动画有问题。一开始,一切都很顺利。但是,当应用程序运行一段时间(大约 10 分钟)时,动画就会滞后。
这是 viewDidLoad 中的代码:
[NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(updateImage) userInfo:nil repeats:YES];
and in -(void)updateImage: //图像淡入
[aSubview release];
[aSubview removeFromSuperview];
aSubview = [[UIImageView alloc] initWithFrame:CGRectMake(28, 64, 265, 284)];
aSubview.image = [slideShowArray objectAtIndex:randNum];
[aSubview setAlpha:0.0];
[UIImageView beginAnimations:NULL context:nil];
[UIImageView setAnimationDuration:2.0];
[aSubview setAlpha:1.0];
[UIImageView commitAnimations];
[self.view addSubview:aSubview];
UIImageView *film = [[UIImageView alloc] initWithFrame:CGRectMake(20, 34, 280, 344)];
film.image = [UIImage imageNamed:@"film5.png"];
[film setAlpha:1.0];
[self.view addSubview:film];
[film release];
谁能解释一下?是内存问题还是其他原因?提前致谢。
【问题讨论】:
-
什么是
slideShow,什么是aSubview? -
就像其他人提到的那样,这主要是一种记忆。这是整个
updateImage:方法吗? -
我已经添加了其余的代码,并稍作修改。
-
现在您正在删除一个子视图,但仍有电影图像。如果不需要,您也应该像 aSubview 一样删除它们。我已经编辑了我的答案。
-
问题好像解决了!感谢大家的快速和建设性的回应!这就是我喜欢stackoverflow的原因!!谢谢你们!
标签: iphone xcode animation uiimageview