문제

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.

도움이 되었습니까?

해결책

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

다른 팁

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? :/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top