Segue problem in xcode and swift

Anyone have idea how to make segue only work after some code executed first in swift…

Yes: you call ‘performSegue(withIdentifier:)’ programmatically when the code has been executed. Make sure the source of the segue is the view controller, not a button or other control in the view controller in your storyboard.

the problem is the button that trigger the segue…:frowning:

So you receive the button action, then in the action you use performSegue(withIdentifier:sender:). I think what Ross means is that the sender in the function should be self and not the IBOutlet that you might have referring to your UIButton.

Its hard to understand like this…can give example bcs i tired to search in google but cant find the answer…:sob:

You know how to hook up a button from the Storyboard, right?

@IBAction func annotateButtonAction(_ sender: UIBarButtonItem) {
    performSegue(withIdentifier: "AnnotationSegue", sender: self)
}

Can it be done like that??? It didnt need override ?and can will perform segue call in ib action?

You generally don’t override ‘performSegue’. Sometimes you override ‘prepareSegue’, but the code in that function only gets called after the transition to the new view controller has already started, which is too late to start setting conditions in code about whether you want to transition at all.

yeah i know that…thats y i asked how to make the code executed first befor perform segue function call.

this work…really help ty