How to create an alert box in iphone?

后端 未结 10 2168
我寻月下人不归
我寻月下人不归 2020-12-23 21:30

I would like to make an alert type box so that when the user tries to delete something, it says, \"are you sure\" and then has a yes or no for if they are sure. What would b

10条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-23 22:04

    Here i provided the alert message, which i used in my first app:

    @IBAction func showMessage(sender: UIButton) {
        let alertController = UIAlertController(title: "Welcome to My First App",
                                  message: "Hello World",
                                  preferredStyle: UIAlertControllerStyle.alert)
        alertController.addAction(UIAlertAction(title: "OK",
                                                style: UIAlertActionStyle.default,
                                                handler: nil))
        present(alertController, animated: true, completion: nil)
    }
    

    with appropriate handlers for user responses.

提交回复
热议问题