UIView animations canceling any touch input?

2019-01-09 08:42发布

问题:

I have a UIScrollView here where I'm adding displaying a label in the middle of the screen when the user has scrolled to a page, the problem is that while the animation is going the user can't scroll to the next page (all user interaction seem to be disabled) until the animation is over.

Here's my code for displaying the label.

if(!scrollView.dragging)
    [UIView animateWithDuration:0.3
                          delay:0.3
                        options:UIViewAnimationOptionCurveEaseOut
                     animations:^(void){
                         [vesselNameLabel setFrame:frame];
                     }
                     completion:^(BOOL finished){}];

So how would I get out of this canceling user interaction on the scrollview?

回答1:

Okay, so I figured this out.

Turns out UIView's block animation by default blocks user interaction, and to get around it you need to pass UIViewAnimationOptionAllowUserInteraction as one of the options. Hopefully someone else will have some use of this information as well.



回答2:

we noted a strange behaviour if alpha becomes 0 ... touches are ignored.