As I didn't get a proper answer, I was forced to fix this issue as pointed out by @hoang Van Ha.
In the custom cell class:
I hid the button by overriding setSelected method as follows:
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
if (self.cellContainerView.frame.origin.x == 0) {
self.trashButton.hidden = YES;
}
}
at the beginning of the gesture methods, i.e. pan
and swipe
I show the button again and on completing the gesture, I check if the frame of the container view has origin zero. If so, the button should be hidden.
- (IBAction)handleSwipeGesture:(UISwipeGestureRecognizer *)recognizer
{
self.trashButton.hidden = NO;
if ( recognizer.direction == UISwipeGestureRecognizerDirectionRight ) {
[UIView animateWithDuration:0.2
animations:^{
self.cellContainerView.frame = CGRectMake(0, self.cellContainerView.frame.origin.y, 320, self.cellContainerView.bounds.size.height);
}
completion:^(BOOL finished) {
self.trashButton.hidden = YES;
}
];
}
}
In the controller class, in cell for row method, do the same process.
if (cell.cellContainerView.frame.origin.x == 0) {
cell.trashButton.hidden = YES;
}
Please feel free to comment, or even post a better answer!