Skip to content

Commit

Permalink
Added better, much more reliable method for grabbing the right view (…
Browse files Browse the repository at this point in the history
…instead of iterating through superviews, just pick the view attached to the gestureRecognizer.)
  • Loading branch information
harlanhaskins committed Nov 29, 2013
1 parent 7c13ea5 commit 1b31fca
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions SWTableViewCell/SWTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 1b31fca

Please sign in to comment.