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

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

Hello,



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.

Definition:

Code:
@property (assign, nonatomic) UITabBarController *tbController;
Alloc:

Code:
    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];
Dealloc:

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

Code:
- (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, 01:26 PM   #2
Reflejo
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, 01:28 PM   #3
dejo
Moderator
 
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

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Memory Issues Hombrelobo iPhone 3 Jan 5, 2014 03:24 PM
My iPhone 5 Has Memory Issues ;( angelwings iPhone Tips, Help and Troubleshooting 4 May 7, 2013 12:31 PM
Memory issues jlrathke Mac Basics and Help 2 Jan 20, 2013 01:11 PM
Resolved: UITabBarController show only 1 tab igorladessa iPhone/iPad Programming 1 Dec 19, 2012 07:52 AM
Memory issues martva Mac Pro 2 Sep 4, 2012 08:51 AM

Forum Jump

All times are GMT -5. The time now is 04:16 AM.

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

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