Is it possible to accept gesture while animating?
s951736 opened this issue · comments
Hi, thanks for sharing the great work.
It works well on my project, but my project needs the ability to keep accepting gestures of the user, wondering if this can be done with Bubble Transition?
Hey @s951736
it should work fine, but it's hard to tell without more details. On top of my mind I could suggesting impelmenting the gesture's delegate method:
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldBeRequiredToFailBy otherGestureRecognizer: UIGestureRecognizer) {
return true
}
Hello, I should provide more detail.
Now my project is pretty simple, there are only two VC in it, and first VC has a button which triggers the segue with bubble transition (just like the demo project). The second VC has an UITapGestureRecognizer that detect tap for the whole VC. I hope the second VC can start to detect user's tapping right after the button in first VC been pressed, even when the bubble animation is running. (Now the animation duration is set to 0.5 as default so in this period of time it can't receive user's tapping)
Sorry, I'm pretty new to coding, so I can't fully understand the method you provided above, I tried adding the code to second VC but it still not accept gesture while animating.
Any suggestion would be appreciated!
In your second VC set the delegate of the gesture to self
, something like this:
someGesture.delegate = self
then add protocol conformity to your controller and add the aforementioned method. I like to do so in a separate extension at the bottom of the file:
extension SecondViewController: UIGestureRecognizerDelegate {
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
}
Change SecondViewController
with your controller's name
Thanks for the reply.
I tried the code but it seems not working. The second VC conformed to UIGestureRecognizerDelegate itself, so I add the func to the VC directly without using the extension, here is the code:
//TapVC is the second VC
class TapVC: UIViewController, UIGestureRecognizerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
let tap = UITapGestureRecognizer(target: self, action: #selector(handleTap(sender:)))
tap.delegate = self
self.view.addGestureRecognizer(tap)
}
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
}
Does the gesture work if you use a standard transition? Because I reckon this is not an issue with this lib.
Closing this for inactivity, reopen if you have more info.