Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIButton not responding when animating

Tags:

objective-c

For some reason my UIButton won't respond to UIControlEvents while animating. Here's how I animate:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:[duration intValue]];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
// change parent UIView's frame
[UIView commitAnimations];

When it reaches the end, it will let me tap it... but not while it's animating. I am using UIControlEventTouchUpInside, by the way.

Thanks.

like image 678
iosfreak Avatar asked Feb 20 '23 15:02

iosfreak


1 Answers

You should set the UIViewAnimationOptionAllowUserInteraction animation option

easier done with block animations:

[UIView animateWithDuration:[duration intValue] options:UIViewAnimationOptionAllowUserInteraction animations^{
    //set parent UIView's frame
}];
like image 131
wattson12 Avatar answered Feb 22 '23 03:02

wattson12