Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread Display Modes
Old Dec 15, 2008, 07:40 AM   #1
macrumors newbie
Join Date: Dec 2008
UITabBarController and memory issues


I'm using a tabbarcontroller which i create programatically, when i release the controller without touch any tabitem dealloc works great and all viewcontrollers are deallocated. If i touch some tabBarItem after the realese, tabbarcontroller doesn't release viewcontrollers.

There is a small example similar to what i'm doing.


@property (assign, nonatomic) UITabBarController *tbController;

    NSMutableArray *tbControllers = [[NSMutableArray alloc] initWithCapacity:3];

    View1 *view1 = [[View1 alloc] init];
    view1.tabBarItem.title = @"1";
    [tbControllers addObject:view1];
    [view1 release];

    View2 *view2 = [[View2 alloc] init];
    view2.tabBarItem.title = @"1";
    [tbControllers addObject:view2];
    [view2 release];
    self.tbController = [[UITabBarController alloc] init];
    tbController.viewControllers = tbControllers;
    tbController.view.frame = CGRectMake(0,0, 320, 320);
    [tbControllers release];
    [self.view addSubview:tbController.view];

     [tbController release];
View1 is an empty UIViewController with a debug output in viewDidLoad and dealloc. View2 too.

- (void)viewDidLoad {
     NSLog(@"INIT view1");
     [super viewDidLoad];

- (void)dealloc {
     NSLog(@"DEALLOCING 1");
     [super dealloc];
I'm missing something or there is a bug?.
Reflejo is offline   0 Reply With Quote
Old Dec 15, 2008, 12:26 PM   #2
Thread Starter
macrumors newbie
Join Date: Dec 2008
Also i've noticed that retainCount of each ViewController (inside tabbarController) increase by 1 every time i switch tabbaritem so when i release tabbarcontroller views are not deallocated.

Any idea why?

Thank you
Reflejo is offline   0 Reply With Quote
Old Dec 15, 2008, 12:28 PM   #3
dejo's Avatar
Join Date: Sep 2004
Location: The Centennial State
In which method are you calling that Alloc code?
dejo is offline   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Lion and graphics issues QuantumLo0p Mac OS X 10.7 Lion 0 Nov 19, 2011 11:31 AM
tabBar and memory issue? MACloop iPhone/iPad Programming 5 Mar 23, 2010 03:06 AM
UITabBarController and only showing 1/2 of tab bar skunkworker iPhone/iPad Programming 8 Sep 27, 2009 02:34 PM
UITabBarController and didReceiveMemoryWarning: North Bronson iPhone/iPad Programming 0 Apr 29, 2009 06:01 PM
UITabBarController and UINavigationController together??? belsokar iPhone/iPad Programming 5 Jan 7, 2009 09:53 AM

All times are GMT -5. The time now is 08:17 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013,, LLC