【发布时间】:2011-04-28 07:59:51
【问题描述】:
一个UITabBarController'sviewControllers是navigationController,当我释放tabbarcontroller时,我发现内存不会释放?
【问题讨论】:
标签: iphone ios uitabbarcontroller
一个UITabBarController'sviewControllers是navigationController,当我释放tabbarcontroller时,我发现内存不会释放?
【问题讨论】:
标签: iphone ios uitabbarcontroller
如果在 .xib 文件中创建它们,则无法释放它们。 它们将被释放,然后您的应用程序结束工作!!!
【讨论】:
如果您正在编写代码,您可能需要在将导航控制器添加到 tabBarController 后释放它们...
tabBarController = [[UITabBarController alloc] init];
NSMutableArray *controllerArray = [[NSMutableArray alloc] initWithCapacity:2];
UINavigationController *localNavigationController;
AccountViewController *accountViewController = [[AccountViewController alloc] init];
localNavigationController = [[UINavigationController alloc] initWithRootViewController:accountViewController];
[controllerArray addObject:localNavigationController];
[localNavigationController release];
[accountViewController release];
AccountHistoryViewController *accountHistoryViewController = [[AccountHistoryViewController alloc] init];
localNavigationController = [[UINavigationController alloc] initWithRootViewController:accountHistoryViewController];
[controllerArray addObject:localNavigationController];
[localNavigationController release];
[accountHistoryViewController release];
[tabBarController setViewControllers:controllerArray];
[controllerArray release];
【讨论】:
- (void)dealloc {
[tabbarcontroller release];
[window release];
[super dealloc];
}
【讨论】: