2
votes

I am trying to display certain subview on the cell of table when user swipes across cell. I am using block animation provided by iOS.

I am registering for swipe gesture in ViewDidLoad method of UITableViewController using following code.

UISwipeGestureRecognizer *showExtrasSwipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(cellSwipe:)];
        showExtrasSwipe.direction = UISwipeGestureRecognizerDirectionLeft;
        [self.tableView addGestureRecognizer:showExtrasSwipe];

When user swipes across the cell, I am initiating flip animation using following code.

-(void)cellSwipe:(UISwipeGestureRecognizer *)gesture
{

 NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ActionsCell" owner:self options:nil];
   ActionsCell* actionView = (ActionsCell *)[nib objectAtIndex:0];   
[UIView transitionWithView:swipedCell duration:0.5
                       options:UIViewAnimationOptionTransitionFlipFromLeft
                    animations:^ { [swipedCell addSubview:actionView]; }
                    completion:nil];

}

With above implementation, I have observed that the flip animation duration is not constant and sometimes animation is not smooth. I observed that if I swipe across the cell quickly then the animation is smooth. But if I swipe littlebit slowly, i.e. take some more time for swiping, the flip animation is not smooth and sometimes animation is not at all visible.

Could it be because I have set duration of animation as 0.5 second, and some of the time taken by slow swipe reduces available duration for animation? Is there any way to check that swipe has ended? I am using iOS 4.3

Appreciate your help !!

1

1 Answers

1
votes

We finally resolved this by implementing a workaround of slightly increasing duration of transition from 0.5s to 0.8s. Not yet sure though what could be the correct solution.