views:

73

answers:

1

My view controller is set to load the view from Nib file. At some point in viewDidAppear I may change the self.view and the view may disappear, next time viewDidAppear I may decide to load original view from the nib, how would I do that?

A: 

One way to do it is to simply re-initialize your controller property object in the viewDidAppear:

[self setMySubViewController:[[[MySubViewController alloc] initWithNibName...] autorelease]];

Your mySubViewController property will release the previous copy of the view controller and retain the new one.

Hope this helps.

hmm.. I don't see how this is going to work in my case. I have 1 controller, no subviewcontrollers. I would have called self initWithNibName but I guess it's not right way. Need to reestablish all outlets with self.
Michael
You can't reference your controller in a container controller then using delegates notify the container controller to re-init your child controller view?
There is no child controller. There is only 1 controller and 2 nib files. I need to change the view in viewDidLoad. The File owner of those 2 nibs are same controller.
Michael
Ok, I see now, this was not clear to me from your original question.My idea still works though, simply create a parent controller and during the parent's ViewDidLoad event, init your child controller to nib view 1. In your child controller, when you hit the ViewDidLoad event, notify the parent controller via delegate that it needs to re-init with the second nib file.Important note: make sure to pass an argument to indicate which view you are loading now to avoid an infinite recursion condition.