Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. @IBAction func pushedRefresh(sender: AnyObject) {
  2. var refreshAlert = UIAlertView()
  3. refreshAlert.title = "Refresh?"
  4. refreshAlert.message = "All data will be lost."
  5. refreshAlert.addButtonWithTitle("Cancel")
  6. refreshAlert.addButtonWithTitle("OK")
  7. refreshAlert.show()
  8. }
  9.  
  10. var refreshAlert = UIAlertController(title: "Refresh", message: "All data will be lost.", preferredStyle: UIAlertControllerStyle.Alert)
  11.  
  12. refreshAlert.addAction(UIAlertAction(title: "Ok", style: .Default, handler: { (action: UIAlertAction!) in
  13. print("Handle Ok logic here")
  14. }))
  15.  
  16. refreshAlert.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: { (action: UIAlertAction!) in
  17. print("Handle Cancel Logic here")
  18. }))
  19.  
  20. presentViewController(refreshAlert, animated: true, completion: nil)
  21.  
  22. let refreshAlert = UIAlertController(title: "Refresh", message: "All data will be lost.", preferredStyle: UIAlertControllerStyle.alert)
  23.  
  24. refreshAlert.addAction(UIAlertAction(title: "Ok", style: .default, handler: { (action: UIAlertAction!) in
  25. print("Handle Ok logic here")
  26. }))
  27.  
  28. refreshAlert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { (action: UIAlertAction!) in
  29. print("Handle Cancel Logic here")
  30. }))
  31.  
  32. present(refreshAlert, animated: true, completion: nil)
  33.  
  34. var refreshAlert = UIAlertController(title: "Log Out", message: "Are You Sure to Log Out ? ", preferredStyle: UIAlertControllerStyle.Alert)
  35.  
  36. refreshAlert.addAction(UIAlertAction(title: "Confirm", style: .Default, handler: { (action: UIAlertAction!) in
  37. self.navigationController?.popToRootViewControllerAnimated(true)
  38. }))
  39.  
  40. refreshAlert.addAction(UIAlertAction(title: "Cancel", style: .Default, handler: { (action: UIAlertAction!) in
  41.  
  42. refreshAlert .dismissViewControllerAnimated(true, completion: nil)
  43.  
  44.  
  45. }))
  46.  
  47. presentViewController(refreshAlert, animated: true, completion: nil)
  48.  
  49. let alertController = UIAlertController(
  50. title: "Your title", message: "Your message", preferredStyle: .alert)
  51. let defaultAction = UIAlertAction(
  52. title: "Close Alert", style: .default, handler: nil)
  53. //you can add custom actions as well
  54. alertController.addAction(defaultAction)
  55.  
  56. present(alertController, animated: true, completion: nil)
  57.  
  58. @IBAction func showAlertDialog(_ sender: UIButton) {
  59. // Declare Alert
  60. let dialogMessage = UIAlertController(title: "Confirm", message: "Are you sure you want to Logout?", preferredStyle: .alert)
  61.  
  62. // Create OK button with action handler
  63. let ok = UIAlertAction(title: "OK", style: .default, handler: { (action) -> Void in
  64. print("Ok button click...")
  65. self.logoutFun()
  66. })
  67.  
  68. // Create Cancel button with action handlder
  69. let cancel = UIAlertAction(title: "Cancel", style: .cancel) { (action) -> Void in
  70. print("Cancel button click...")
  71. }
  72.  
  73. //Add OK and Cancel button to dialog message
  74. dialogMessage.addAction(ok)
  75. dialogMessage.addAction(cancel)
  76.  
  77. // Present dialog message to user
  78. self.present(dialogMessage, animated: true, completion: nil)
  79. }
  80.  
  81. func logoutFun()
  82. {
  83. print("Logout Successfully...!")
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement