سؤال

I have a UITapGestureRecognizer set up which performs a 0.8s UIView animation. What I’m trying to do is allow the user to interrupt during that 0.8s. I’ll handle the animation side of things (i.e. making the thing animate from its current position), but the current issue is that any further taps during those 0.8s do not call the @selector from the recognizer. Any subsequent taps are blocked until the first run through the @selector is finished.

Just to confirm, what I need is a means of allowing the same @selector from the same UITapGestureRecognizer to be called, even if it didn’t return yet. At that point I can override the animation, tell it to begin from its current position, and have it complete even if the user spams the recognizer.

Is there a way to do this? I considered threading, but I’m under the impression I shouldn’t be doing UI updates on background threads so I’m hesitant to try that when there’s likely a preferred way.

هل كانت مفيدة؟

المحلول

well, if you want to allow user interaction during animation, add UIViewAnimationOptionAllowUserInteraction option, here is example,

[UIView animateWithDuration:0.8
                      delay:0.0
                    options:UIViewAnimationOptionAllowUserInteraction
                 animations:^{
                     // your animations
                 } completion:^(BOOL finished) {
                     // completion
                 }];
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top