UIView animations canceling any touch input?
Asked Answered
P

2

23

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?

Preteritive answered 7/5, 2011 at 12:52 Comment(0)
P
65

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.

Preteritive answered 7/5, 2011 at 21:1 Comment(3)
I've also noticed that it blocks by default in iOS 4, but it doesn't in iOS 5. I only came across this issue when I tested on a colleague's phone who is still running iOS 4.Faline
Blocks by default in iOS 6.Weever
Awesome, so simple :)Lammers
P
0

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

Pronounce answered 15/3, 2018 at 10:31 Comment(1)
That is as expected. Invisible views don't capture input.Unbalance

© 2022 - 2024 — McMap. All rights reserved.