Skip to content
This repository has been archived by the owner on Sep 11, 2022. It is now read-only.

Fix swipe to delete behavior in UITableViews #226

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Source/PKRevealController/PKRevealController.m
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,31 @@ + (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key

#pragma mark - Gesture Recognition

// Fixes swipe to delete behavior in UITableViews
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
UITableView *tableView;

if ([otherGestureRecognizer.view.superview isKindOfClass:UITableView.class])
{
tableView = (UITableView *)otherGestureRecognizer.view.superview;
}
if ([tableView.delegate respondsToSelector:@selector(tableView:canEditRowAtIndexPath:)])
{
if ([gestureRecognizer isKindOfClass:UIPanGestureRecognizer.class])
{
UIPanGestureRecognizer *panGestureRecognizer = (UIPanGestureRecognizer *)gestureRecognizer;
CGPoint velocity = [panGestureRecognizer velocityInView:tableView];
// On swiping when in edit mode, don't want to open the reveal at the same time
if (velocity.x < 0.0)
{
return YES;
}
}
}
return NO;
}

- (void)didRecognizeTapGesture:(UITapGestureRecognizer *)recognizer
{
if (self.state != PKRevealControllerShowsFrontViewController)
Expand Down