当用户单击按钮时,它会显示一个带有两个视图控制器的新选项卡栏视图控制器。我是这样做的
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];
this works fine. I dismiss that view controller with a dismiss
method in both the ACLevelDownloadController
and ACInstalledLevelsController
. That also works fine. What's strange is that the memory usage goes up when I present the view controller
but it never goes back down. If I present it again, it goes up even more
I'm using ARC. Why is the memory that the view controllers use not being released after they are dismissed?
EDIT
他们被解雇的方式都是ACLevelDownloadController
and ACInstalledLevelsController
连接 IBActions,单击它们时调用此方法
- (void)dismiss:(id)sender{
[self dismissViewControllerAnimated:YES completion:nil];
}
从内存使用图中我们可以观察到 tabViewController 没有被正确地关闭并且它在堆栈中累积。在关闭时,您必须允许呈现 tabViewController 的 viewController 关闭它。解雇是其责任。还要保留 Outlets 的弱引用,并将任何强引用分配给 nil**viewWillDisapper:。您可以以模态方式呈现 viewController 作为临时中断,以从用户那里获取重要信息。如果不是这种情况,您可以删除模态呈现。检查这个link https://stackoverflow.com/questions/8852685/tabbar-memory-management。希望这可以帮助 :)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)