iPhone对象没有死亡

时间:2012-04-23 05:13:07

标签: iphone animation uiviewcontroller profiling automatic-ref-counting

我在我的应用中使用ARC。 现在我遇到了一个真正的问题。我需要从左到右为两个视图控制器设置动画。所以我只是在按钮动作中为两个视图设置动画,例如,

// 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];
}

并且在第二个视图控制器中我做了同样的操作,但改变了动画方向。

我真正的问题是当我运行这段代码时,每次我创建另一个类的对象并且它没有解除分配。通过分析此代码,发现每次对象处于活动状态并且它不会死亡并且内存分配会增加。

1 个答案:

答案 0 :(得分:1)

您可以在启用引用计数记录的情况下运行分配工具。然后根据该数据评估偏移量与预期的差异。

相关问题