アプリでARCを使用しています。今、私は本当の問題に直面しました。2つのViewControllerを左から右にアニメーション化する必要があります。だから私はボタンアクションで2つのビューを次のようにアニメーション化します
// thanks to stackoverflow for this code
test *control = [[test alloc] initWithNibName: @"test" bundle: nil];
control.view.frame = self.view.frame;
control.view.center = CGPointMake(self.view.center.x + CGRectGetWidth(self.view.frame), self.view.center.y);
[self.view.superview addSubview: control.view];
// Animate the push
[UIView beginAnimations: nil context: NULL];
[UIView setAnimationDelegate: self];
[UIView setAnimationDidStopSelector: @selector(pushAnimationDidStop:finished:context:)];
control.view.center = self.view.center;
self.view.center = CGPointMake(self.view.center.x - CGRectGetWidth(self.view.frame), self.view.center.y);
[UIView commitAnimations];
- (void) pushAnimationDidStop: (NSString *) animationID finished: (NSNumber *) finished context: (void *) context
{
[self.view removeFromSuperview];
}
2番目のViewControllerでも同じことをしましたが、アニメーションの方向を変更しました。
私の本当の問題は、このコードを実行するときに、別のクラスのオブジェクトを作成するたびに、割り当てが解除されないことです。このコードをプロファイリングすることにより、オブジェクトが生きていて死んでいないたびに、メモリ割り当てが増加していることがわかりました。