PDA

View Full Version : How to remove all UINavigationController objects from memory




99miles
Apr 23, 2009, 07:23 PM
I have a main view showing with a button that will open a navigation controller:


pView = [[PreferencesViewController alloc] init];
navigationController = [[UINavigationController alloc] initWithRootViewController:pView];
[pView release];
[ window addSubview:[navigationController view] ];


Then you can navigate within the navigation controller to other views which are pushed on like:


[[self navigationController] pushViewController:subViewController animated:YES];


But when you back up out of the navigation it will remove all those views:


[[navigationController view] removeFromSuperview];
[navigationController release];
navigationController = nil;


But only the dealloc of the rootViewController is getting called. How would I go about removing all the other views that were opened in the navigation?
I would have thought that by clearing out the navigationContoller that would take care of it, but apparently not.