views:

312

answers:

1

I have an navigation bar based app and while in a UIViewController I get a memory warning while selecting a photo. It is handled but when I pop the viewcontroller and go back to the top level viewcontroller the navigation bar is blank. Everything else gets reloaded but not the navigation bar buttons and title.

I know that viewDidUnload was called on the top level view controller and when I navigate back to it the VC gets reloaded again with viewDidLoad but the navigation bar is not loaded there, it comes from the mainwindow.xib. Any ideas what I'm doing wrong? (OS 3.2, iPad)

EDIT Here's an excerpt from the console log showing what's happening at the time of the memory warning:

09:55:25.864 -[PhotoBox setPhotoImage:] size {1536, 2048} 
09:55:26.169 -[PhotoBox setPhotoImage:] resized to {768, 1024} 
09:55:26.180 Received memory warning. Level=1 
09:55:26.236 ClockMakerVC: viewDidUnload 
09:55:26.240 -[ClockMakerVC didReceiveMemoryWarning] 
09:55:26.271 saving 1 state objs to /var/mobile/Applications/82F2C13B-8663-4241-A603-B2BAD29691C1/Documents/ViewItem_State_Data 
09:55:26.298 -[ItemSettingsVC didReceiveMemoryWarning]

At this point I hit the navigation bar back arrow to return to the parent view controller, which causes a viewDidLoad on it (since it was previously unloaded):

09:55:44.477 read 1 state objs from /var/mobile/Applications/82F2C13B-8663-4241-A603-B2BAD29691C1/Documents/ViewItem_State_Data 
09:55:44.479 loadSavedItems: 295376119.689 opts=0 np=2 P=(284,402,200,200) L=(412,274,200,200) 1 PhotoBox 
09:55:44.484 ClockMakerVC: viewDidLoad: 1 saved items loaded
A: 

According to the documentation viewDidLoad is "...used to perform additional initialization steps on views that are loaded from nib files."

I had always thought that viewDidLoad was only called once and only recently realized how it is called again after a memory warning (after a view is unloaded and then later reloaded).

Parts of my main view controller's init code in viewDidLoad didn't work quite right when called a second time. I fixed parts of it and move parts of it to awakeFromNib and that solved the problem.

progrmr
which parts specifically ?
Floetic