UIView animations can interfere with touch events

Update: This issue went away as of Xcode 4.3.  I’ll leave the code up in GitHub just in case someone cares to look at animating via UIView vs. CABasicAnimation.

I created a simple expand/collapse button that would rotate an arrow image 180 degrees with each button press (as associated content was collapsed or expanded).  Somewhat similar to the ComboBox control with drop down content as seen on Windows.

   

That worked fine, but then I tried to get fancy and add in a 90 degree rotation on UIControlEventTouchDownInside (which would revert back on UIControlEventTouchUpOutside or complete on UIControlEventTouchUpInside).

Now all of a sudden the control would no longer receive the touch up inside notification if the user did a quick click (i.e. if the touch down animation was still running when the touch up event occurred).  Switching to a CALayer animation resolved the issue.  (I suppose I could also have tried adjusting the timing of the UIView animation, such as dispatching it via GCD or using performSelector:withObject:afterDelay.)

Anyway, I created an iPad sample app that has 2 versions of the control side-by-side to see the difference in the behavior and also has a switch to turn off the midway rotation on touch down.  The project can be found on GitHub here.

Author: Mark

Mark is an American computer programmer living in Switzerland.