Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't touch during animation (Block Animation)

I have a View with UIButton, UITextField, and a UIImageView for Background.

in viewDidLoad i try animate UIImageView from alpha=0 to alpha =1 using block. it's pretty basic, here's the code:

[UIView animateWithDuration:1.5 animations:^(void){

    ((UIView*)[self.view viewWithTag:123]).alpha = 1;
}completion:^(BOOL finished){
}];

which is working fine. but during that 1.5 seconds of animation, my touch in current view seems to be disabled. i can't click any of the buttons or textFields until animation finish.

Thanks in Advance

like image 922
HelmiB Avatar asked Oct 14 '11 07:10

HelmiB


Video Answer


1 Answers

You should use option UIViewAnimationOptionAllowUserInteraction as in the following example:

[UIView animateWithDuration:1.0 
                      delay:0 
                    options:UIViewAnimationOptionAllowUserInteraction 
                 animations:^{ myView.alpha = 0.5; } 
                 completion:NULL];
like image 141
d.lebedev Avatar answered Nov 09 '22 08:11

d.lebedev