views:

45

answers:

1

Hi! first of all... i'm italian, so i'm sorry for my bad english!

so... this is my app: i'm using a navigation controller: in the first view there are 10 buttons and every button calls a functions like this:

    [self pushViewController:nameview animated:YES];

to a different uiviewcontroller! So i have 11 uiviewcontroller! Every controller is decleared like here

@interface ...
IBoutlet UIViewController *viewcontroller;
...
@property (nonatomic, retain) IBOutlet UIViewController *viewcontroller;

Finally i have to say that i'm working with IB!

My problem is that my app doesn't release memory! when i'm in a view and i tap on the "backbuttonitem" (created by IB, not by me) the last view doesn't became released (again, sorry for my bad english)... and if an user see all 10 view, the app receive a warning massage (low-memory)!

How can i release the last view saw before the popviewcontroller action?

thanks :D

A: 

When you push a view controller onto a navigation controller you need to release it as the navigation controller now owns it. For example you would do the following:

UIViewController *controller = [[UIViewController] initWithNibName:@"Nib" bundle:nil];
[self pushViewController:controller animated:YES];
[controller release];

Then when you use popViewControllerAnimated: the navigation controller will take care of making sure the view controller is released from memory.

rickharrison
sorry but i'm a really newbie :Pso... my navigation controller is "X", i'm in the view "A" and i want to push in the view "B"i've tried with this:UIViewController *B = [[UIViewController] initWithNibName:@"Nib" bundle:nil];[self pushViewController:B animated:YES];[B release];but xcode tell me "expected : before ] token" O_Owhere is the mistake?
JJSaccolo
i don't understant why i have to do thisUIViewController *controller = [[UIViewController] initWithNibName:@"Nib" bundle:nil];because i've used IB to create the uiviewcontroller...
JJSaccolo
You shouldn't use IB to create the view controller if it isn't shown right away. You really should only create the controller when it needs to be shown.
rickharrison