From 1b31fca28540e7f9c621e590375632bb72e19ecb Mon Sep 17 00:00:00 2001 From: Harlan Haskins Date: Thu, 28 Nov 2013 22:53:10 -0500 Subject: [PATCH] Added better, much more reliable method for grabbing the right view (instead of iterating through superviews, just pick the view attached to the gestureRecognizer.) --- SWTableViewCell/SWTableViewCell.m | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/SWTableViewCell/SWTableViewCell.m b/SWTableViewCell/SWTableViewCell.m index f7e4d499..bd2a3b96 100644 --- a/SWTableViewCell/SWTableViewCell.m +++ b/SWTableViewCell/SWTableViewCell.m @@ -112,18 +112,12 @@ - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecogni // scroll the cell sideways when that is their true intent. if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) { - // Grab the tableView to which this scrollView is added by iterating through its superviews. - UIView *viewToCheck = self; - - while (![viewToCheck isKindOfClass:[UITableView class]]) { - viewToCheck = viewToCheck.superview; - } - // Find the current scrolling velocity in that view, in the Y direction. - CGFloat yVelocity = [(UIPanGestureRecognizer*)gestureRecognizer velocityInView:viewToCheck].y; + CGFloat yVelocity = [(UIPanGestureRecognizer*)gestureRecognizer velocityInView:gestureRecognizer.view].y; // Return YES if and only iff the user is not actively scrolling up. return fabs(yVelocity) <= 0.25; + } return YES; }