View Full Version : What happens to views in navigation controller
Jan 19, 2009, 09:15 AM
Does anyone know what happens to a viewcontroller that is moved to the left as a new view is pushed onto the stack?
For example if the viewcontroller is pushed onto the stack and whilst in display is modified. Then another view is pushed onto the stack and scrolls in from the right.
When this final view is popped off the stack resulting in the previous view coming back into view should this returning view still retain the modified state and not the state it was originally in when pushed on the stack?
Jan 19, 2009, 10:11 AM
In most cases the view controller that is hidden and then revealed doesn't change at all.
However, in the case of a memory warning a hidden view controller will have its view unloaded and then reloaded. After the view is reloaded the view controller will appear to have reverted to a previous state, unless things are coded specifically to work around this.
Also, when the view controller reappears its viewWillAppear and viewDidAppear methods are called. Depending on how they're written the view may be updated with new data. For example if you have a table that pushes a detail view that allows the user to edit something then when the detail view is popped the table should update itself with the new values.
Jan 19, 2009, 10:29 AM
HI, really appreciate your answer thanks and in digesting it I looked at this bit of code in my app:
-(void) viewWillAppear: (BOOL) animated
imageView.image = image;
[super viewWillAppear: animated];
Now I am trying to find the book and section which said you should do this, but when I commented it out the app runs exactly as I want it to, i.e not reverting to the initialising image!
Jan 19, 2009, 12:47 PM
Perhaps try moving the "imageView.image = image;" into viewDidLoad.