7

当用户单击一个按钮时,它会显示一个带有两个视图控制器的新标签栏视图控制器。这是我的做法

ACLevelDownloadController *dvc = [[ACLevelDownloadController alloc] initWithNibName:@"ACLevelDownloadController" bundle:[NSBundle mainBundle]];
ACInstalledLevelsController *ivc = [[ACInstalledLevelsController alloc] initWithNibName:@"ACInstalledLevelsController" bundle:[NSBundle mainBundle]];
UITabBarController *control = [[UITabBarController alloc] init];
control.viewControllers = @[dvc, ivc];
dvc.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFeatured tag:0];
ivc.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemDownloads tag:1];
[self presentViewController:control animated:YES completion:nil];

这很好用。我使用和中的dismiss方法解除了该视图控制器。这也很好用。奇怪的是,当我展示视图控制器时,内存使用量上升了 ACLevelDownloadControllerACInstalledLevelsController在此处输入图像描述

但它永远不会退缩。如果我再次展示它,它会上升得更多, 在此处输入图像描述 我正在使用 ARC。为什么视图控制器使用的内存在关闭后没有被释放?

编辑

他们被解雇的方式是同时ACLevelDownloadController连接ACInstalledLevelsControllerIBActions,当他们被点击时调用这个方法

- (void)dismiss:(id)sender{
    [self dismissViewControllerAnimated:YES completion:nil];
}
4

1 回答 1

3

我们可以从内存使用图中观察到 tabViewController 没有被正确关闭并且它在堆栈中建立。在关闭时,您必须允许呈现 tabViewController 的 viewController 关闭它。解雇是它的责任。还要为 Outlets 保留弱引用,并在viewWillDisapper:中为 nil** 分配任何强引用。您可以模态地呈现 viewController 作为临时中断,以从用户那里获取重要信息。如果这里不是这种情况,您可以删除模态呈现。检查此链接。希望这可以帮助 :)

于 2013-06-12T05:54:58.750 回答