Tuesday, 14 March 2017

Action Controller navigating to another New View (Swift3)

//*************** Alert  Action  Controller ***************//

@IBAction func btnAlertAction(_ sender: Any)
{
   
let alertActionSheet = UIAlertController(title: "Menu", message: "",
preferredStyle: .actionSheet)
       
       
let oneAction = UIAlertAction(title: "One", style: .default, handler: { action in self.performSegue(withIdentifier: "mySegueIdentifierOne", sender: self) })
       
let twoAction = UIAlertAction(title: "Two", style: .default, handler: { action in self.performSegue(withIdentifier: "mySegueIdentifierTwo", sender: self) })
  
let closeAction = UIAlertAction(title: "Close", style: .cancel, handler: { action in print("Close")
        })
       
        alertActionSheet.addAction(closeAction)
        alertActionSheet.addAction(oneAction)
        alertActionSheet.addAction(twoAction)

 self.present(alertActionSheet, animated: true)
}

# Note :- You could create a segue in your storyboard, control dragging from the yellow view controller at the top of a scene to a new view controller. Then give that segue an identifier in the inspector. You can call that from the handler in your code.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home