Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UIKit
- class ViewController: UIViewController, UIGestureRecognizerDelegate {
- @IBOutlet weak var tapView: UIImageView!
- override func viewDidLoad() {
- super.viewDidLoad()
- // create an instance of UITapGestureRecognizer and tell it to run
- // an action we'll call "handleTap:"
- let tap = UITapGestureRecognizer(target: self, action: Selector("handleTap:"))
- // we use our delegate on ourself
- tap.delegate = self
- // allow for user interaction
- tapView.userInteractionEnabled = true
- // add tap as a gestureRecognizer to tapView
- tapView.addGestureRecognizer(tap)
- }
- override func didReceiveMemoryWarning() {
- super.didReceiveMemoryWarning()
- // Dispose of any resources that can be recreated.
- }
- func handleTap(sender: UITapGestureRecognizer? = nil) {
- // just creating an alert to prove our tap worked!
- let tapAlert = UIAlertController(title: "hmmm...", message: "this actually worked?", preferredStyle: UIAlertControllerStyle.Alert)
- tapAlert.addAction(UIAlertAction(title: "OK", style: .Destructive, handler: nil))
- self.presentViewController(tapAlert, animated: true, completion: nil)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement