I'm writing my own SplitViewController from scratch (i.e. by subclassing UIViewController
and not UISplitViewController
).
It has two sub-viewControllers (one for the left panel and one for the detail right panel), to which I need to send the appropriate messages (viewWillAppear, viewDidAppear, viewWillDisapppear and viewDidDisappear
).
I am already forwarding those messages when my custom SplitViewController receives them and it works fine. However I am struggling to figure out when to send them when any of the two sub-viewcontrollers is replaced by a new one, which also needs to receive those messages. I am adding the view of the new UIViewController
properly but the messages are not called adequately.
My initial approach was to call them in the setter of the sub-viewControllers, calling viewWillDisappear
to UIViewController
about to be released and viewWillAppear
to the new UIViewController
set, but this one is executed before viewDidLoad
and therefore I presume is wrong.
I have also seen that UIView has a method didAddSubview:
that might be useful to know when to call viewDidAppear
on the correspondent UIViewController
.
Any help would be much appreciated!
If you want to mirror UISplitViewController, it seems best to just have dummy UIViewControllers that print out whenever each method is called.
As for your current problem of the ordering of viewWillDisappear, viewWillAppear and viewDidLoad, just do: