【发布时间】:2013-05-30 20:27:12
【问题描述】:
我已经开始在我的新应用中使用 CoreAnimation,我使用 CA 来制作一些很酷的动画。但我是目标 C 的新手,这对我来说很难,我正面临这个大问题:
我制作了一个自定义 UIView:customView,我使用 xib 来获取用户界面并设置 IBOutlet,自定义视图是一个简单的小视图,里面有一个 UIImageView。
在我的视图控制器中,我创建了一个插入多个 customView 的循环,在这个循环中,我为视图和 imageView 设置了一个 CAnimation:
for (int i = 0 ; i < 8 ; i ++ )
{
CABasicAnimation *balanceAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
// ... set Animation here...
[customView.myImgView.layer addAnimation:balanceAnimation forKey:nil];
CABasicAnimation *moveUp3Bis;
// ... setting animation here...
moveUp3Bis.repeatCount = 1;
[customView.layer addAnimation:moveUp3Bis forKey:nil];
}
只要视图控制器在 10 秒延迟后是当前控制器,我就调用此循环
所以视图会被动画化、移动并移到主窗口旁边,但经过很长时间动画会变得越来越慢......
我当然明白我的循环添加到堆栈太多customView,视图没有释放(可能是因为动画还在?)
我认为视图会在一段时间后发布,但我认为视图将永远移动。 可能我需要设置一个指向我的视图的指针并在延迟后释放它吗? 我确定 CA 已经为这样的案例计划了一些东西?
但我不知道我能做什么?
感谢您的帮助。
【问题讨论】:
-
您可能正在使用其他一些资源(如视图)而不是动画。您的视图是否已从其父级中删除? (
-[UIView removeFromSuperview])
标签: ios animation ios6 core-animation