0

I am trying to fire event with UITapGestureRecognizer on different uiview but it is not working.

var tap = UITapGestureRecognizer(target: self, action: Selector("tappedMe"))
        AUIView.addGestureRecognizer(tap)
        AUIView.tag = 1

BUIView.addGestureRecognizer(tap)
        BUIView.tag = 2


   func tappedMe()
    {

        if AUIView.tag == 1
        {
            println("1")
        }
         else if BUIView.tag == 2
        {
            println("2")
        }
}
ak2g
  • 1,673
  • 15
  • 22

1 Answers1

1

You cannot add the same gesture recognizer to multiple views. This answer explains why.

Either declare a new gesture recognizer, or create a copy of the existing one before adding it to the other view.

BUIView.addGestureRecognizer(tap.copy())
Community
  • 1
  • 1
ZeMoon
  • 20,054
  • 5
  • 57
  • 98