Qing
Qing

Reputation: 1411

prepareForSegue never got called even though I set the segue in storyboard

Im new to iOS development, Im trying to follow the course in Udacity.

But having trouble in performing the segue.

the prepareForSegue never got called in my second viewcontroller.

I have two viewcontroller, one is ViewController, the other is PlaySoundViewController.

enter image description here

and I have link those from story board to the real class in swift.

enter image description here


enter image description here


enter image description here

and I have drag from the first view controller to second one to generate a segue and named it as "gonext".

enter image description here

and I called performSegueWithIdentifier("gonext", sender:aduio);

and in the second view controller I implement the prepareForSegue, however, it never got called.... but it managed to go to the next view.enter image description here

Upvotes: 1

Views: 416

Answers (1)

Stefan DeClerck
Stefan DeClerck

Reputation: 1192

To go to the next view controller you have to perform the method

Self.performSegueWithIdentifier("gonext", sender:aduio);

The one thing that you are getting wrong is that you have to run the prepareForSegue method in the first view controller and not the second view controller to send the data.

So instead of running the prepareForSegue method in the second view controller just run it in the first.

Upvotes: 3

Related Questions