[:en]Swift: Alert Message and Actions[:]

[:en]Alert message and actions

    import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        
    }
    
    @IBAction func Alert(_ sender: Any) {
        showAlertDelete()
    }
    
    // Yes or No warning
    func showAlertDelete(){
        // Warning
        let myAlert = UIAlertController(title:"Delete?", message:"Are you sure?", preferredStyle: UIAlertController.Style.alert);
        let noAction = UIAlertAction(title:"Cancel", style:UIAlertAction.Style.default){ action in
           print("No")
        }
        myAlert.addAction(noAction);
        let yesAction = UIAlertAction(title:"Yes", style:UIAlertAction.Style.default){ action in
            print("Yes")
        }
        myAlert.addAction(yesAction);
        self.present(myAlert, animated:true, completion:nil);
    }

}


[:]

Print Friendly, PDF & Email
Scroll to Top