Closed turabhassan89 closed 7 years ago
Conceptually, they should work the same...so it's a bug somewhere.
Some things to look at:
userInteractionEnabled
I was making one gesture recognizer and then attaching it to both the circle and cross imageviews and it was working only for one. I had to make two separate ones, conceptually what is happening?
This doesnt work:
let panGesture = UIPanGestureRecognizer(target: self, action: #selector(handlePan(_:))) cross.addGestureRecognizer(panGesture) circle.addGestureRecognizer(panGesture)
This works:
let panCircleGesture = UIPanGestureRecognizer(target: self, action: #selector(handlePan(_:))) let panCrossGesture = UIPanGestureRecognizer(target: self, action: #selector(handlePan(_:))) cross.addGestureRecognizer(panCircleGesture) circle.addGestureRecognizer(panCrossGesture)
Each gesture recognizer can only be hooked up to one view. When you add the same gesture recognizer to two views, it will be removed from the first view when you add it to the second.
Think about why it would be confusing for the system to apply the same gesture recognizer to multiple views. What would happen when you accessed 'recognizer.view'?
I have setup the gesture reconizer for both circle and cross but it seems to be only working for the circle and I cant figure out why.