【问题标题】:Release/dealloc tab bar view controllers释放/释放标签栏视图控制器
【发布时间】:2012-02-13 03:17:37
【问题描述】:

我已经使用 nib 文件分配了标签栏视图控制器,当我尝试释放标签视图控制器时,它没有调用任何视图控制器的 dealloc 函数。我发布如下:

[appDelegate.tabBarController.view removeFromSuperview];
NSMutableArray * vcs = [NSMutableArray arrayWithArray:[appDelegate.tabBarController viewControllers]];
[[vcs objectAtIndex:2] release]; //tried releasing both ways
[vcs removeObjectAtIndex:2];
[[vcs objectAtIndex:1] release];
[vcs removeObjectAtIndex:1];
[[vcs objectAtIndex:0] release];
[vcs removeObjectAtIndex:0];
[appDelegate.tabBarController setViewControllers:vcs];

请帮帮我。

【问题讨论】:

    标签: iphone objective-c ios ipad memory-management


    【解决方案1】:

    您不需要在视图控制器上显式调用release。 它们由数组保留,因此从数组中删除它们就足够了。

    实际上,如果视图控制器没有被保留在其他地方,您可能会“过度释放”并且应该预期在此代码运行后会崩溃......

    所以在其他地方寻找这个。 Instruments 是你的朋友。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多