UIViewAnimation blocks user interaction
I have a UIView following the users finger as they move it around inside my app. Sometimes, other things on screen are animating with UIViewAnimation blocks, but this freezes the tracking of their finger, so if they continue moving their finger during the animation, it won't follow. How can i stop the animation from blocking up the mai开发者_如何学Cn thread?
Try using UIViewAnimationOptionAllowUserInteraction
with [UIView animateWithDuration:delay:options:animations:completion:]
you can use the NSObject's method: performSelector:onThread:withObject:waitUntilDone:
More details in Apple NSObject Documentation
If there is any other thing on the screen is animated, that would also be done in main thread. And the current finger tracking would also be done in main thread. So definitely there would be some blocking.
To get rid of that, we can optimize our code using blocks and GCD.
Note that if you link for iOS 5 this problem will go away all by itself. Under iOS 5, block-based animation of a view does not turn off user interaction for other views. This is what Apple should have done in the first place.
精彩评论