Advertisement
thieumao

Gesture Recognize Swift

May 16th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 1.33 KB | None | 0 0
  1. import UIKit
  2.  
  3. class ViewController: UIViewController {
  4.  
  5.     @IBOutlet weak var imageView: UIImageView!
  6.    
  7.     override func viewDidLoad() {
  8.         super.viewDidLoad()
  9.         // Do any additional setup after loading the view, typically from a nib.
  10.         imageView.userInteractionEnabled = true
  11.        
  12.         let gesture = UITapGestureRecognizer(target: self, action: #selector(actionSelected(_:)))
  13.         self.imageView.addGestureRecognizer(gesture)
  14.        
  15.         let gesture2 = UILongPressGestureRecognizer(target: self, action: #selector(actionLongSelected(_:)))
  16.         self.imageView.addGestureRecognizer(gesture2)
  17.        
  18.        
  19. //        let gesture = UITapGestureRecognizer(target: self, action: "actionSelected:")
  20. //        self.imageView.addGestureRecognizer(gesture)
  21. //        let gesture2 = UILongPressGestureRecognizer(target: self, action: "actionLongSelected:")
  22. //        self.imageView.addGestureRecognizer(gesture2)
  23.     }
  24.    
  25.     func actionSelected(gestureRecognize: UIGestureRecognizer){
  26.         print("Tap here!")
  27.     }
  28.    
  29.     func actionLongSelected(gestureRecognize: UIGestureRecognizer){
  30.         print("Tap Long here!")
  31.     }
  32.  
  33.     override func didReceiveMemoryWarning() {
  34.         super.didReceiveMemoryWarning()
  35.         // Dispose of any resources that can be recreated.
  36.     }
  37.  
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement