This question has been asked before, but the answered ones I could find were from 2009 and don't suit my problem. Let me reiterate the issue.
I have a UINavigationController
that spawns and pushes lots of different UIViewController
s onto its stack. One of those deals with some Core Data operations that need to be saved when that one particular VC get's popped off the stack. Don't focus on the Core Data part, it's about the popping.
How can I hook into the moment that the UIViewController
is going to be popped off the stack?
UINavigationControllerDelegate
protocol is very sparse.viewWillDisappear
, but that one is also called if another view is pushed onto the stack, so it doesn't provide the right moment.viewWillAppear
of the view controller that we're 'popping to', but since that call doesn't have a reference to the VC that needs to do the checking, this is unsatisfactory and will introduce a level of dependency that is counter productive (the VC is used by several NCs).That leaves me in my current unsatisfied state of mind. Is there anyone out there with a better solution to finding the moment your UIViewController is popped off a UINavigationController's stack?
Cheers,
EP.
viewWillDisappear
is the appropriate delegate. You will need to add logic within this method if you want to determine if the current view is being popped or a new view is being pushed. That's been answered here - viewWillDisappear: Determine whether view controller is being popped or is showing a sub-view controller
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With