开发者

iOS: How to make Gesture recognizer more responsive when animation is happening?

I have 4 subviews in a UIViewController page arranged as a grid. Sometimes, animations will be running on the subviews. I am trying to recognize taps on one of the subviews (using UITapGestureRecognizer).

Now, the when animation is not running, taps are recognized smoothly. But, when an a开发者_C百科nimation is running, most of my taps are not recognized at all (even when animation is running on another subview).

Is there any way to increase priority of the Gesture recognizer than the animation ? Any suggestions are appreciated. Thanks


The issue was due to setting animation options as 0. After adding UIViewAnimationOptionAllowUserInteraction as the animation option, it works nicely.


This sounds like a classic case of the main thread being clogged up. Multithreading will solve your problem.

Do something like this:

-(void)performAnimations{
    //Do your animations in this method
}

Once you have your animations in a separate method, you're free to do this:

[self performSelectorInBackground:@selector(performAnimations)];

This will leave your main thread free to recognize the touch events :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜