I use UINavigationController in my program,when I situated on forth or fifth controller in navigation stack,program recieve memory warning and I can’t go backwards. I press back button, navigation bar animation is taking place,but controller isn’t being popped,I still see old view. Can anyone help me handle this problem?
My subviews has property:
@property (nonatomic,retain) UITableView *searchTableView;
@property (nonatomic,retain) UISegmentedControl *categorySegmentedControl;
@property (nonatomic,retain) UISearchBar *searchTableBar;
@property (nonatomic,retain) UIView *footerView;
@property (nonatomic,retain) UINavigationItem *navigationItem;
My viewDidUnload method
- (void)viewDidUnload
{
[super viewDidUnload];
self.searchTableView = nil;
self.categorySegmentedControl = nil;
self.searchTableBar = nil;
self.navigationItem = nil;
self.footerView = nil;
}
My dealloc
-(void)dealloc
{
[super dealloc];
[searchTableView release];
[categorySegmentedControl release];
[searchTableBar release];
[navigationItem release];
[footerView release];
[currentValues release];
}
And I had noticed strange regularity – this bug appears only when I move from view without tab bar to view with tab bar.
It sounds like you may be doing some setup in your controller’s viewDidLoad and/or releasing stuff in viewDidUnload that should be done in initWithNibName:bundle and dealloc instead.
viewDidLoad and viewDidUnload are not called when your controller is created and destroyed, they are called when the view inside your controller is created and destroyed, and this can happen at any time, especially if you receive a memory warning when the view controller is in the background (e.g. not the top view in a navigation controller).
Make sure that you write your controllers in such a way that if the viewDidUnload gets called, or if the viewDidLoad gets called multiple times, you won’t lose data or break anything.
Sorry if this answer is a bit vague, but if you post the code for your view controllers, I can probably give you more specific advice.