1

I searched through stackOverflow but could not find the answer for my problem. So, I decide to ask a seemingly old question.

My example (xcode 5) has 2 views: one is a login button view (login) and the other is an empty destination view (dest).

In dest.m, I put below @implementation:

@implementation testViewController

- (IBAction)unwindToTest:(UIStoryboardSegue*) segue
{
   NSLog(@"Segue unwindToTest works");
}

I ctrl-drag the login button to Exit in storyboard and select unwindToTest. I also write prepareForSegue in login.m:

@implementation loginViewController
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    NSLog(@"Prepare for Segue to unwind to Plan List");
}

I main.m, I aslo put:

NSLog(@"Starting from main");

to keep track of the flow.

Building returns success. The login view appears, but when I click login button, nothing happens. I check the log, it only shows "Starting from main".

Really appreciate your comments. Huynh.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
huynhhp
  • 11
  • 1
  • I'm unclear on the layout... can you include a little diagram of the order of the views on the storyboard, and how you're trying to unwind? Or at least a more detail explanation on the order of events. – nhgrif Nov 24 '13 at 02:51
  • possible duplicate of [What are Unwind segues for and how to use them?](http://stackoverflow.com/questions/12561735/what-are-unwind-segues-for-and-how-to-use-them) – nhgrif Nov 24 '13 at 02:53
  • nhgrif: Thanks. I looked at "What are unwind ..." before posting. Here is the layout: https://dl.dropboxusercontent.com/u/7376655/Screen%20Shot%202013-11-24%20at%2011.15.31%20AM.png – huynhhp Nov 24 '13 at 03:18
  • Your setup is still unclear. What is that table view controller? Your login controller is the initial controller, so what are you unwinding from? It makes no sense to unwind from the initial controller. – rdelmar Nov 24 '13 at 03:41
  • rdelmar: I want to connect Login to the testViewController. I do not want to use model/push segue. When click login, it goes to testViewController (then, display a list of result). Can we use unwind for this? – huynhhp Nov 24 '13 at 03:44
  • No, unwinds are for going back to a previous controller. Why don't you want to use a modal or push? – rdelmar Nov 24 '13 at 03:48
  • if push or modal, can I still use prepareForSegue to pass data to the destination view? – huynhhp Nov 24 '13 at 03:53
  • Yes, if you mean a modal or push segue (not calling pushViewController or presentViewController in code). All segues call prepareForSegue. – rdelmar Nov 24 '13 at 03:55
  • Then, we identify the push/model segue through it Identifier? Can you give a simple code example? If possible, can you refer me to a tutorial :-). I almost went through the Apple "Start Developing iOS Apps". Thanks a lot for your response so far. – huynhhp Nov 24 '13 at 04:01
  • Sorry, I don't use tutorials, so I can't recommend one. If you want to go to the next controller on a button click, just control drag from the button to the next controller and choose modal (or push, but only if you embed the login controller in a navigation controller). You don't need any code to do that. – rdelmar Nov 24 '13 at 04:17
  • I can create push/model connection but I am not sure how to pass data from the source controller to destination controller :| – huynhhp Nov 24 '13 at 04:26

0 Answers0