6

I'm trying to find a method to catch a return from a segue to the root controller so I can run custom code that will make a decision on where to go next. I've tried the two methods below and they don't do the trick as they seem to (obviously) be concerned with unwinding a segue stack. Any thoughts out there?

-(UIStoryboardSegue *)segueForUnwindingToViewController
{
}

-(BOOL)canPerformUnwindSegueAction
{
}
mttrb
  • 8,046
  • 2
  • 32
  • 54
Grymjack
  • 479
  • 1
  • 9
  • 20
  • 1
    Take a look at http://stackoverflow.com/questions/12569316/does-anyone-know-what-the-new-exit-icon-is-used-for-when-editing-storyboards-usi/13437054#13437054 – Chris Wagner Jan 22 '13 at 08:10
  • Thanks for you answer. Sorry, I wasn't as clear as I should be in my question (edited). What I am really trying to do is catch the segue as it unwinds to the root controller so I can run custom code, not unwinding a segue stack. – Grymjack Jan 22 '13 at 08:50

3 Answers3

6

Just for iOS 6:

"In the controller you wish to return to, implement a method that returns an IBAction, and that takes a single UIStoryboardSegue argument:

- (IBAction)returnActionForSegue:(UIStoryboardSegue *)returnSegue {

// do useful actions here.

}

Now, in the scene we wish to unwind, control-drag from the UI element that will trigger the return to the scene's exit icon (the green icon in the dock). In the popup menu, select the previously defined return item."

more here: http://www.freelancemadscience.com/fmslabs_blog/2012/9/24/advanced-storyboard-techniques.html

Drakes
  • 20,841
  • 3
  • 44
  • 84
TonyMkenu
  • 7,367
  • 3
  • 25
  • 47
  • Sorry for the long wait on the response. I'm not sure I understand your answer. Here is the sequence: VC1->VC2 if profile selected then move to main screen, if not then modal segue to profile selection screen, profile is selected, segue released back to VC2. What I need at VC2 is a way to detect the return from the modal segue and then do a segue to main screen. How would the (IBAction) catch the return? I realize that this is probably a bad question, I plead noobish. If there is a better way to structure this, please let me know as part of my continuing education. – Grymjack Jan 25 '13 at 13:57
  • I don't know if I understand exactly... check the example from the link (I made it in hurry) - you have 3 VC (VC1, VC2, VC3); when "unwind" from VC2 to VC1, VC1 "detect unwind" and then will go to VC3 https://dl.dropbox.com/u/19438780/testSegue-Unwind.zip – TonyMkenu Jan 26 '13 at 04:42
  • Thanks that was very helpful to see actual running code. I appreciate your help. – Grymjack Jan 26 '13 at 23:17
  • This is exactly what I was looking for. If I could have given you more than one upvote, I would have! – Joseph DeCarlo Sep 05 '13 at 18:58
  • @JosephDeCarlo glad to help you. Pay it forward! :) – TonyMkenu Sep 09 '13 at 07:58
2

Your method calls are incomplete. Here is another post that gives some good examples of how to use the unwind method:

What are unwind segues for and how to use them

Community
  • 1
  • 1
  • Thanks for answering, I've edited the question to be more clear. Trying to catch the segue exiting to the root controller so I can run some custom code at that point. Looking for a method that I can put that code in. – Grymjack Jan 22 '13 at 08:52
0

if you just need to know when your VC is being Deleted from the Stack then be aware of the boolean isMovingFromParent.

Check for isMovingFromParent in either viewWillDisappear or viewDidDisappear to ensure your view is about to-be no more.

aklektik
  • 789
  • 1
  • 10
  • 29