The best practice for such application would be to use a UINavigationController
for navigation. If you are navigating using UINavigationController
then viewDidLoad will only get called when you go from A to B but will not be called when you go back from C to B controller
how to get view controller storyboard id or restortionIdentifier in backwards navigation?
-
08-07-2023 - |
Question
In my navigation I have a rootViewController (AController), a second ViewController (BController) and a third one (CController). I can navigate my app by pushing A --> B --> C.
When I go back from C --> B, in BController:viewdidLoad
how can I get I'm navigating from C and not from A?
I tried to use self.presentedViewController.restorationIdentifier
but it always return me the identifier of AController, not the CController one.
Should I use the storyboardID property? how can I do that?
Any help is appreciated.
Solution
OTHER TIPS
Try using delegation to set a property in B When loading C and going back to B again.
Also, as @khawar-ali mentioned, viewDidLoad
only gets called when loading the view controller for the first time hence viewDidLoad
method won't get called when going back from C. Try ViewWillAppear
/viewDidAppear
instead? :/