私はIOS開発に不慣れです。私のアプリケーションには、アニメーション化するいくつかの画像があります。画像の数はさまざまです。
iPad 2で実行している場合、アニメーションは正常に機能します。多数の画像(20以上)であるipad 1で実行すると、アプリがクラッシュしてメモリ警告が表示されます。
アニメーションに必要なメモリ量を事前に計算したいと思います。この図に基づいて、アニメーションを実行するか、最終的なステータスにスキップするかを計算できます。
これはどのように行うことができますか?
編集:
私の現在のコード:
- (void)remix
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:animationDuration];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:
@selector(animationDidStop:finished:context:)];
self.currentStatus = canvas_status_animating;
NSMutableArray *circles = [[NSMutableArray alloc] init];
for (CircleView* view in self.subviews)
{
if(![view isKindOfClass:[CircleView class]])
continue;
[circles addObject:view];
}
[self animatePosition:circles];
[UIView commitAnimations];
}
-(void) animatePosition:(NSArray*)circles
{
int maxWidth = self.bounds.size.width;
int maxHeight = self.bounds.size.height;
for (CircleView* view in circles)
{
int selectedX = 0;
int selectedY = 0;
if ((arc4random()%200)+1 > 100)
{
selectedX = (arc4random() % maxWidth) + 1;
selectedY = (arc4random() % 200) + 1;
selectedY = (selectedY > 100) ? (maxHeight - selectedY) : selectedY;
}
else
{
selectedX = (arc4random() % 200) + 1;
selectedX = (selectedX > 100) ? (maxWidth - selectedX) : selectedX;
selectedY = (arc4random() % maxHeight) + 1;
}
view.frame = CGRectMake(selectedX - view.frame.size.width / 2,
selectedY - view.frame.size.height / 2,
view.frame.size.width,
view.frame.size.height);
}
}