tap gesture recognizer - which object was tapped?

前端 未结 12 1288
萌比男神i
萌比男神i 2020-12-29 17:47

I\'m new to gesture recognizers so maybe this question sounds silly: I\'m assigning tap gesture recognizers to a bunch of UIViews. In the method is it possible to find out w

12条回答
  •  北海茫月
    2020-12-29 18:27

    func tabGesture_Call
    {
         let tapRec = UITapGestureRecognizer(target: self, action: "handleTap:")
         tapRec.delegate = self
         self.view.addGestureRecognizer(tapRec)
         //where we want to gesture like: view, label etc
    }
    
    func handleTap(sender: UITapGestureRecognizer) 
    {
         NSLog("Touch..");
         //handling code
    }
    

提交回复
热议问题