【发布时间】:2012-06-29 06:01:31
【问题描述】:
我遇到了推送和弹出 UIViewController 的问题。我有两个 UIViewController 说 A 和 B。
我写了一个IBAction,其中我从A 推送到B 喜欢,
B *bView=[[B alloc] initWithNibName:@"B" bundle:nil];
[UIView beginAnimations:@"animation" context:nil];
[UIView setAnimationDuration:0.7];
[self.navigationController pushViewController:bView animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
[bView release]; //Problem is here, If I comment this line, it works fine! else it crashes after my some transitions from A [push] B, B [pop] A.
现在在B 我已经写了一个IBAction 来弹出到A,如下所示
[UIView beginAnimations:@"animation" context:nil];
[UIView setAnimationDuration:0.7];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[self.navigationController popViewControllerAnimated:NO];
[UIView commitAnimations];
我也从B 打电话给[super dealloc]
-(void) dealloc
{
[super dealloc];
}
如果我不释放bView,它将不会调用dealloc,并且可能会产生内存问题。
这是因为我应用了动画造成的吗?
我尝试了所有其他方式,例如autorelease、设置bView=nil; 等,但这些对我不起作用!
任何帮助,建议!
【问题讨论】:
-
【bView release】没有问题;您的 B 类代码中还有其他问题,您可以使用 NSZombie 来跟踪问题的确切位置。或者您可以粘贴 B 类的代码。
-
NSZombie 已启用,它显示消息
message sent to deallocated reference -
它会显示一些内存地址,在控制台上你可以使用“po memory-address”查看是哪个实例导致了这个问题。
标签: iphone ios release dealloc pushviewcontroller