A UITabBarController's
viewControllers
are navigationCont开发者_C百科roller
, when I release the tabbarcontroller
, I found the memory would not released ?
You cant release them if you create them in .xib file. They will be released then your application end work !!!
If you are working in code you probably need to release the navigationControllers after adding them to the 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];
you should release them in dealloc method of app delegate class
- (void)dealloc {
[tabbarcontroller release];
[window release];
[super dealloc];
}
精彩评论