如何发布tabbarcontroller?

时间:2011-04-28 07:59:52

标签: iphone ios uitabbarcontroller

UITabBarController's viewControllersnavigationController,当我发布tabbarcontroller时,我发现内存不会被释放?

3 个答案:

答案 0 :(得分:0)

如果在.xib文件中创建它们,则无法释放它们。 他们将在你的申请结束后被释放!!!

答案 1 :(得分:0)

你应该在app delegate class

的dealloc方法中释放它们
- (void)dealloc {

   [tabbarcontroller release]; 
   [window release];
    [super dealloc];
}

答案 2 :(得分:0)

如果你正在使用代码,你可能需要在将它们添加到tabBarController后释放navigationControllers ...

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];