I need a way of calling the viewDidLoad method when the ‘back’ button is pressed in the UINavigationController. So for example if I have a flow like so:
View A -> View B -> View C
I need the it so that if I’m on View C and I press back, View B‘s viewDidLoad method should be called. Similarly, if I’m on View B and I press the back button View A‘s viewDidLoad method should be called.
Please can someone suggest how to achieve this?
The
viewDidLoadmethod is called when the view controller has finished loading and setting up the view controller, for example loading the NIB file. For your needs, you should move the relevant code toviewWillAppearwhich will be called each time the corresponding view controller becomes visible. So for a transitionA -> B -> C (backto)-> BtheviewWillAppearmethod ofB‘s view controller will be called twice.