Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unwind segue not working

I'm currently doing the tutorial from Apple's Start Developing iOS Apps.

On the Tutorial: Storyboards page (link above), I'm told to make custom classes for two views. For simplicity I'll call them the Table View (has a table) and the Add View (has a text field to add items to the table).

The Table View has a button that links opens up the Add View, and the Add View has two buttons on its navigation bar: Cancel and Done.

I was told to write an empty method unwindToList in the .m file of the Add View:

- (IBAction)unwindToList:(UIStoryboardSegue *)segue
{

}

Then I was told to link both Cancel and Done buttons to the Exit item in the Scene Dock (see image at the bottom), and to pick the method unwindToList. As a result, this is what's supposed to happen, as quoted from the tutorial:

Now, run your app. At launch, you see a table view—but there’s no data in it. You can click the Add button and navigate to [the Add View] from [the Table View]. You can click the Cancel and Done buttons to navigate back to [the Table View]."

However, when I click Cancel or Done, nothing happens at all. I'm sure both are linked.

Thanks in advance!

Tutorial Image

like image 527
Fares K. A. Avatar asked May 18 '14 12:05

Fares K. A.


1 Answers

If you read the tutorial carefully you will see that the unwind method needs to be in the UIViewController that you are unwinding to - from the tutorial -

An unwind segue is created by adding an action method to the destination view controller (the view controller you want to unwind to).

...

Because you want to unwind back to XYZToDoListTableViewController, you need to add an action method with this format to the XYZToDoListTableViewController interface and implementation.

So, you should create your unwindToList method in the table view controller, not in the add view controller.

like image 105
Paulw11 Avatar answered Oct 15 '22 23:10

Paulw11