PDA

View Full Version : didReceiveMemoryWarning implementation for navigation controller interface




Mac Me Up
Sep 3, 2008, 09:30 PM
Supposing I have 3 views:
top
middle
end
Set up with a navigation controller eg:
top -> middle -> end
in top:

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

in middle:

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

and to move back up

[[self navigationController] popViewControllerAnimated:YES];


So this structure works just fine to drill up and down my views. My problem is that if I am at my last view, and I simulate a memory warning, and then drill back down to the middle view, my middle view has been reset (eg: all the controls are back to the defaults, not to how the user might have changed them).

Is there a piece of the puzzle I'm missing here? The documentation seems to say that my view will only be released if it's not part of the view hiearchy. Do I have to do more than just a push to get it into the view hiearchy?



DipDog3
Sep 4, 2008, 08:40 AM
Supposing I have 3 views:
top
middle
end
Set up with a navigation controller eg:
top -> middle -> end
in top:

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

in middle:

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

and to move back up

[[self navigationController] popViewControllerAnimated:YES];


So this structure works just fine to drill up and down my views. My problem is that if I am at my last view, and I simulate a memory warning, and then drill back down to the middle view, my middle view has been reset (eg: all the controls are back to the defaults, not to how the user might have changed them).

Is there a piece of the puzzle I'm missing here? The documentation seems to say that my view will only be released if it's not part of the view hiearchy. Do I have to do more than just a push to get it into the view hiearchy?

Are you releasing it? Can you just save the view info and reload when shown.

Mac Me Up
Sep 4, 2008, 09:38 AM
I'm not explicitly releasing it no, but when the memory warning is issued it gets released. I guess I could save the object that populates that view and re-populate it every time it loads...is that normal behaviour then?