Segue and Button programmatically swift

Create seuge

Create Seuge

Assign identifier

enter image description here

and your button target

 @IBAction func button_clicked(_ sender: UIButton) {
        self.performSegue(withIdentifier: "segueToNext", sender: self)
 }

 override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if segue.identifier == "segueToNext" {
        if let destination = segue.destination as? Modo1ViewController {
            destination.nomb = nombres // you can pass value to destination view controller

            // destination.nomb = arrayNombers[(sender as! UIButton).tag] // Using button Tag
        }
    }
 }

Leave a Comment