4

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.

iosfreak
  • 5,228
  • 11
  • 59
  • 102

1 Answers1

8

You should set the UIViewAnimationOptionAllowUserInteraction animation option

easier done with block animations:

[UIView animateWithDuration:[duration intValue] options:UIViewAnimationOptionAllowUserInteraction animations^{
    //set parent UIView's frame
}];
wattson12
  • 11,176
  • 2
  • 32
  • 34
  • 1
    according to [this question](http://stackoverflow.com/questions/8346100/uibutton-cant-be-touched-while-animated-with-uiview-animatewithduration) the touchable frame of the button isnt always aligned with the visible frame, so you may need to do some custom touch handling – wattson12 Aug 05 '12 at 22:22
  • +1, thanks it helped me for ios 4. as ios 5 & 6 doesnt need this method :) – mAc Oct 10 '12 at 10:14