Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

beardedpig

macrumors member
Original poster
Dec 17, 2008
57
0
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?
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
It depends.

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.
 

beardedpig

macrumors member
Original poster
Dec 17, 2008
57
0
HI, really appreciate your answer thanks and in digesting it I looked at this bit of code in my app:

Code:
-(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!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.