Note that there are some explanatory texts on larger screens.

plurals
  1. POGet notified when a view controller is about to be popped in iOS4
    primarykey
    data
    text
    <p><em>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.</em></p> <p>I have a <code>UINavigationController</code> that spawns and pushes lots of different <code>UIViewController</code>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.</p> <p><strong>How can I hook into the moment that the <code>UIViewController</code> is going to be popped off the stack?</strong></p> <ul> <li>I was hoping for a delegate method of some sort, but couldn't find it. The <code>UINavigationControllerDelegate</code> protocol is very sparse.</li> <li>I then started thinking of using <code>viewWillDisappear</code>, but that one is <em>also called if another view is pushed <strong>onto</strong> the stack</em>, so it doesn't provide the right moment.</li> <li><a href="https://stackoverflow.com/questions/920379/uinavigationcontroller-intercepting-popviewcontrolleranimated">This answered question, from 2009</a>, opts to look at the <code>viewWillAppear</code> 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).</li> <li><a href="https://stackoverflow.com/questions/642312/checking-if-a-uiviewcontroller-is-about-to-get-popped-from-a-navigation-stack">Another answered question, also from 2009</a>, opts to subclass UINavigationController and rewrite the popViewControllerAnimated: method. Or alternatively use the VC's dealloc. My gut tells me that can't be the way to go.</li> <li>Finally there's <a href="https://stackoverflow.com/questions/5246798/how-to-get-notified-of-popped-view-in-uinavigationcontroller">one last recent question from march 2011</a>, but no one cared to answer it.</li> </ul> <p>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?</p> <p>Cheers,<br> EP.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload