Search code examples
iphoneobjective-cmethodsuikitviewdidload

A method to UINavigationController as "viewDidLoad" to UIViewController


This may be a very stupid question. I'm just wondering

Is there a method that would be called after a NavigationController has been segued?

[which works just like viewDidLoad in UIViewController, besides viewDidLoad is called after the view controller has loaded its view hierarchy into memory]

If there isn't such a thing, is it possible to write one into the UIKit Framework??

(I know we can always use RootViewController's viewDidLoad to trigger something after a NavigationController has been segued. I'm just being curious..)


Solution

  • First, there are no views loaded by a UINavigationController. It just controls UIViewControllers that in turn control views. Therefore there is no need to have a callback like viewDidLoad.

    Second, you already have a place where you can customize the UINavigationController after it has been created: in prepareForSegue: of the calling view controller, or in your app delegate if it is the root navigation controller.

    Of course, you can always subclass UINavigationController and override its init methods if you want to encapsulate your modifications.