Reputation: 136
I'm trying to make a simple swipe up gesture, I dragged the Swipe Gesture Recogniser over a UIImage, I then Ctrl button drag the Swipe Gesture to my swift file and create the following Action: -
@IBAction func swipeDice(sender: UISwipeGestureRecognizer) {
//Test display
testLabel.text = "Zing"
}
The app builds and runs successfully however when I test the swipe gesture it doesn't seem to do anything.
Is that all the code I need for the gesture to run? How do I make it recognise a 2 finger swipe gesture?
Upvotes: 1
Views: 1602
Reputation: 154721
You need to enable User Interaction for the UIImage
that you added the UIGestureRecognier
to:
Open the Attributes Inspector for the UIImage
and tick User Interaction Enabled:
Upvotes: 2
Reputation: 17054
If you created the Swipe Gesture Recognizer in IB you can setup the gesture through the right window.
If you have a conflict between several gestures you can handle this through the UIGestureRecognizerDelegate
protocol.
Upvotes: 1
Reputation: 23078
Add the following function to your code:
func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWithGestureRecognizer otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
Upvotes: 0