Can i know in viewWillAppear that it was called after navigationController pop (back button)?

adsurbum picture adsurbum · Jan 8, 2014 · Viewed 10.4k times · Source

Say I have UIViewController A and B. User navigates from A to B with a push segue. Than user presses back button and comes to A.

Now viewWillAppear of A is called. Can I know in the code here that I came from back button (navigationController popTo...) and not by another way? And without writing special code in the B view controller.

Answer

falsecrypt picture falsecrypt · Jan 8, 2014

hm, maybe you can use self.isMovingToParentViewController in viewWillAppear, see docs, if it is NO then it means the current view controller is already on the navigation stack.