I am using UIAlertView to display alert and it is working for first time that when i click alert appears but when second time i do it then on clicking twice alert gets displayed instead of 1st click.
During secong time "visited full" gets printed on 1st click but alert appears on 2click, Why does this appear?Please help me to resolve.Thanks in advance
println("visited full")
var alert:UIAlertView = UIAlertView(title: "Video", message: "You have played all videos", delegate: self, cancelButtonTitle: "OK")
alert!.show()
IF it doesn't work then try this may be this will work.
let alert = UIAlertController(title: "Video", message: "You have played all videos", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
EDIT: I think you can use it like this way too:
dispatch_async(dispatch_get_main_queue(), {
var alert:UIAlertView = UIAlertView(title: "Video", message: "You have played all videos", delegate: self, cancelButtonTitle: "OK")
alert.show()
})
and for UIAlertController
dispatch_async(dispatch_get_main_queue(), {
let alert = UIAlertController(title: "Video", message: "You have played all videos", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With