-3

When I user alertview in ios 9 with swift, compiler shows this warning message:

UIAlertView' was deprecated in iOS 9.0: UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead

Aleksandr Erokhin
  • 1,904
  • 3
  • 17
  • 32
rahul
  • 1
  • 1
    Yes, like the message says, it's deprecated. Check this like to docs: might solve your issue http://stackoverflow.com/documentation/ios/874/uialertcontroller#t=201607261258026665057 – Idan Jul 26 '16 at 12:59
  • 2
    what is your question? – fantaghirocco Jul 26 '16 at 13:14
  • 3
    Possible duplicate of [UIAlertView first deprecated IOS 9](http://stackoverflow.com/questions/32690086/uialertview-first-deprecated-ios-9) – Mihriban Minaz Jul 26 '16 at 13:20

1 Answers1

0

try using this code

let alert = UIAlertController(title: "TITLE", message: "MESSAGE", preferredStyle: UIAlertControllerStyle.Alert)
            let okAction = UIAlertAction(title:"OK", style: UIAlertActionStyle.Cancel, handler: { (action) -> Void in
            })
            alert.addAction(okAction)
            dispatch_async(dispatch_get_main_queue(),{
                self.presentViewController(alert, animated: true, completion: nil)
            })
Kuntal Gajjar
  • 792
  • 6
  • 12