【发布时间】:2013-06-12 00:34:40
【问题描述】:
当用户单击一个按钮时,它会显示一个带有两个视图控制器的新标签栏视图控制器。这是我的做法
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];
这很好用。我在ACLevelDownloadController 和ACInstalledLevelsController 中都使用dismiss 方法关闭了该视图控制器。这也很好用。奇怪的是,当我展示视图控制器时,内存使用量上升了
但它永远不会退缩。如果我再次呈现它,它会上升更多 我正在使用ARC。为什么视图控制器关闭后使用的内存没有被释放?
编辑
他们被解除的方式是ACLevelDownloadController和ACInstalledLevelsController都连接了IBActions,当他们被点击时会调用这个方法
- (void)dismiss:(id)sender{
[self dismissViewControllerAnimated:YES completion:nil];
}
【问题讨论】:
-
你能提供你用来解散的代码吗?
-
@GabrielePetronella 检查我的编辑
-
您可以尝试在
self.presentingViewController上调用dismiss...方法,而不是在self上调用吗? -
您是否在
ACLevelDownloadController或ACInstalledLevelsController的某些部分使用了块?如果是这样,您能否向我们提供这些块的代码? -
两者都没有块
标签: ios objective-c memory automatic-ref-counting