Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

User interaction during UITableView animation

I have a UITableView where my cells handle all the touches instead of the tableview itself. The cells need to respond to both single and double taps instantaneously. (And yes, that does mean the single tap is called then the double tap afterwards, I want them both called).

The single tap action is to drop in another cell below the tapped cell (the cell is a menu for the above cell). I use insertRowsAtIndexPaths for this. However during that animation user interaction seems to fail completely, so I can't pick up on the second tap to fire off that action.

Using 2 UITapGestureRecognizers (a single and double tap) and setting the single to wait for the double to fail works, but causes noticeable delays in the single tap action.

I know during UIView animations you can flag it UIViewAnimationOptionAllowUserInteraction and it will work fine, however that's not an option in UITableView.

Any thoughts of how I can continue to pick up touch events during the tablview animations?

I've tried using UITapGestureRecognizers, using touchesEnded and touchesBegan, none have registered touches during animations.

like image 977
bclymer Avatar asked Nov 13 '22 00:11

bclymer


1 Answers

Just create your own for loop for performing animation. I used my own recursion logic which looks like animation 0.3 seconds.

NSInteger i = 0;

-(void)recursiveMethod
{
    //Doing Animation task very slowly...
    //For example, Transforming UIView.

    [aView setTransform: CGAffineTransformMakeScale(i/100.0,i/100.0)];

    if(i<100)
    {
        [self performSelector:@selector(recursiveMethod) afterDelay:0.3/100.0];
        i++;
    }
}

And you will be able to perform Touch Action also. Your user interaction will not be desabled by compiler.

like image 173
Mohd Iftekhar Qurashi Avatar answered Dec 09 '22 23:12

Mohd Iftekhar Qurashi