`isMovingToParentViewController`/`isMovingToParent` incorrectly true

Viewed 81

In my view controller, I am checking for isMovingToParent inside viewWillAppear so that I can execute some logic only when the view controller is first displayed and not when a later view controller is popped off the stack to reveal my original one.

I would expect this value to be true when the VC is first pushed onto the navigation stack and false when it appears because of a later VC popping off the stack.

However, in both cases, the value ends up being true. Any reason why this would be happening?

1 Answers

Are you overriding any of the didMove(toParent:)/willMove(toParent:) methods? If so, make sure you are calling super's version of that method. If you fail to do so, the isMovingToParent series of properties seemingly can be incorrectly set.

Note: If anyone has documentation attesting to the above behaviour, please edit the answer :)

Related