Quantcast
Channel: How to create an alert box in iphone? - Stack Overflow
Viewing all articles
Browse latest Browse all 11

Answer by danner.tech for How to create an alert box in iphone?

$
0
0

Being that UIAlertView is now deprecated, I wanted to provide an answer to future coders that come across this.

Instead of UIAlertView, I would use UIAlertController like so:

@IBAction func showAlert(_ sender: Any) {
  let alert = UIAlertController(title: "My Alert", message: "This is my alert", preferredStyle: UIAlertControllerStyle.alert)

  alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.default, handler: {(action) in 
    alert.dismiss(animated: true, completion: nil)
  }))
  self.present(alert,animated:true, completion:nil)
}

Viewing all articles
Browse latest Browse all 11

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>