Search code examples
macosswiftxcode6nsbutton

Change button actions sequence swift


I have a button connected both to @IBAction in ViewController and another ViewController (with another class name). When I press the button, a new ViewController opens, but code in @IBAction is never executed. Is there any way to set the sequence if button actions (first must be @IBAction, and then transition to another ViewController) ?


Solution

  • I don't know why it isn't working, but what you can do is make a manual segue from the first viewController to the second viewController, instead from the button the second viewController.

    Then, in IBAction, programmatically perform this manual segue:

    performSegueWithIdentifier("manualSegue", sender: self) 
    

    To make a manual segue, control drag from the viewController icon to the second viewController. Give this segue an unique identifier and use it in the performSegueWithIdentifier method.