I've successfully implemented gestures that allow users to enlarge and rotate a view using UIGuestureRecognizers. However, the user can't do two gestures at the same time (i.e. rotate and scale at the same time). How can I go about doing that? Below is how I added the gestures
var rotateRecognizer = UIRotationGestureRecognizer(target: self, action: "handleRotate:")
var pinchRecognizer = UIPinchGestureRecognizer(target: self, action: "handlePinch:")
testV.addGestureRecognizer(rotateRecognizer)
testV.addGestureRecognizer(pinchRecognizer)
In swift 3 the delegate method name is:
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
Also you need set delegate for gestures:
rotateRecognizer.delegate = self
pinchRecognizer.delegate = self
Just added this and it works:
func gestureRecognizer(UIGestureRecognizer,
shouldRecognizeSimultaneouslyWithGestureRecognizer:UIGestureRecognizer) -> Bool {
return true
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With