开发者

how to release a tabbarcontroller?

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜