Advertisement
Guest User

Untitled

a guest
Jul 27th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. import UIKit
  2.  
  3. class ViewController: UIViewController, UIGestureRecognizerDelegate {
  4.  
  5. @IBOutlet weak var tapView: UIImageView!
  6.  
  7. override func viewDidLoad() {
  8. super.viewDidLoad()
  9. // create an instance of UITapGestureRecognizer and tell it to run
  10. // an action we'll call "handleTap:"
  11. let tap = UITapGestureRecognizer(target: self, action: Selector("handleTap:"))
  12. // we use our delegate on ourself
  13. tap.delegate = self
  14. // allow for user interaction
  15. tapView.userInteractionEnabled = true
  16. // add tap as a gestureRecognizer to tapView
  17. tapView.addGestureRecognizer(tap)
  18. }
  19.  
  20. override func didReceiveMemoryWarning() {
  21. super.didReceiveMemoryWarning()
  22. // Dispose of any resources that can be recreated.
  23. }
  24.  
  25. func handleTap(sender: UITapGestureRecognizer? = nil) {
  26. // just creating an alert to prove our tap worked!
  27. let tapAlert = UIAlertController(title: "hmmm...", message: "this actually worked?", preferredStyle: UIAlertControllerStyle.Alert)
  28. tapAlert.addAction(UIAlertAction(title: "OK", style: .Destructive, handler: nil))
  29. self.presentViewController(tapAlert, animated: true, completion: nil)
  30. }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement