当我试图停止动画UIActivityIndi​​catorView时内存崩溃

时间:2012-04-13 13:03:57

标签: iphone

我什么时候尝试从线程更新UIActivityIndi​​catorView。该应用程序因抛出异常而崩溃  修改正在最终确定的层 - 0x7e177fd0 - [CALayer removeAnimationForKey:]:发送到解除分配的实例0x7e177fd0的消息。 当我尝试跟踪mallocDebugger工具中的内存泄漏时。

这种崩溃并非始终发生在十分之一的

请帮我解决这个记忆问题

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

[autoRechargeCell addSubview:activityIndicator];
[self.activityIndicator startAnimating];
   if( [PennyTalkAPI getBalanceInfoForAccount:appDelegate.accountNumber withPIN:appDelegate.pinNumber])
{   
    [autoRechargeCell.switchField setOn:[[NSUserDefaults standardUserDefaults] boolForKey:@"AutoRecharge"]];
    [self.activityIndicator stopAnimating];   <<<<<<<<<<<<<<<<<<<<<< 

}
else
{
    [self.activityIndicator stopAnimating];
}

[pool release]; 

这是我写的代码

2 个答案:

答案 0 :(得分:0)

在没有查看代码并看到错误的情况下,我假设您发布了活动指示器,然后您尝试将其设置为动画..

解决方案:在.h文件中声明UIActivityIndicator对象合成并以-(void)dealloc方法释放它。

答案 1 :(得分:0)

这是双重释放错误或悬空指针。您应该在Scheme的配置中启用僵尸检测,并尝试使用仪器中的Zombies仪器。