Skip to content

Commit

Permalink
Merge pull request #50 from mergesort/scroll_enabled
Browse files Browse the repository at this point in the history
Replace scrollEnabled = YES and NO by turning on directionLockEnabled on the tableView
  • Loading branch information
CEWendel committed Dec 18, 2013
2 parents 642f49b + eafaa6a commit 2f31df0
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions SWTableViewCell/PodFiles/SWTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ - (void)initializer
{
[self.scrollViewContentView addSubview:subview];
}

self.containingTableView.directionalLockEnabled = YES;
}

- (void)layoutSubviews
Expand All @@ -152,7 +154,6 @@ - (void)layoutSubviews
self.scrollViewButtonViewRight.layer.masksToBounds = YES;
self.scrollViewContentView.frame = CGRectMake([self leftUtilityButtonsWidth], 0, CGRectGetWidth(self.bounds), self.height);
self.cellScrollView.scrollEnabled = YES;
self.containingTableView.scrollEnabled = YES;
self.tapGestureRecognizer.enabled = YES;
}

Expand Down Expand Up @@ -531,33 +532,36 @@ - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoi

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
self.containingTableView.scrollEnabled = NO;
self.tapGestureRecognizer.enabled = NO;
if (scrollView.contentOffset.x > [self leftUtilityButtonsWidth])
{
CGFloat scrollViewWidth = MIN(scrollView.contentOffset.x - [self leftUtilityButtonsWidth], [self rightUtilityButtonsWidth]);

// Expose the right button view
self.scrollViewButtonViewRight.frame = CGRectMake(scrollView.contentOffset.x + (CGRectGetWidth(self.bounds) - scrollViewWidth), 0.0f, scrollViewWidth,self.height);

CGRect scrollViewBounds = self.scrollViewButtonViewRight.bounds;
scrollViewBounds.origin.x = MAX([self rightUtilityButtonsWidth] - scrollViewWidth, [self rightUtilityButtonsWidth] - scrollView.contentOffset.x);
self.scrollViewButtonViewRight.bounds = scrollViewBounds;
if ([self rightUtilityButtonsWidth] > 0)
{
CGFloat scrollViewWidth = MIN(scrollView.contentOffset.x - [self leftUtilityButtonsWidth], [self rightUtilityButtonsWidth]);

// Expose the right button view
self.scrollViewButtonViewRight.frame = CGRectMake(scrollView.contentOffset.x + (CGRectGetWidth(self.bounds) - scrollViewWidth), 0.0f, scrollViewWidth,self.height);

CGRect scrollViewBounds = self.scrollViewButtonViewRight.bounds;
scrollViewBounds.origin.x = MAX([self rightUtilityButtonsWidth] - scrollViewWidth, [self rightUtilityButtonsWidth] - scrollView.contentOffset.x);
self.scrollViewButtonViewRight.bounds = scrollViewBounds;
}
}
else
{
CGFloat scrollViewWidth = MIN(scrollView.contentOffset.x - [self leftUtilityButtonsWidth], [self leftUtilityButtonsWidth]);

// Expose the left button view
self.scrollViewButtonViewLeft.frame = CGRectMake([self leftUtilityButtonsWidth], 0.0f, scrollViewWidth, self.height);

if ([self leftUtilityButtonsWidth] > 0)
{
CGFloat scrollViewWidth = MIN(scrollView.contentOffset.x - [self leftUtilityButtonsWidth], [self leftUtilityButtonsWidth]);

self.scrollViewButtonViewLeft.frame = CGRectMake([self leftUtilityButtonsWidth], 0.0f, scrollViewWidth, self.height);
}
}
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
self.tapGestureRecognizer.enabled = YES;
self.containingTableView.scrollEnabled = YES;
}

- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
Expand All @@ -566,7 +570,6 @@ - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
self.tapGestureRecognizer.enabled = YES;
if (_cellState == kCellStateCenter)
{
self.containingTableView.scrollEnabled = YES;
self.longPressGestureRecognizer.enabled = YES;
}
}
Expand Down

0 comments on commit 2f31df0

Please sign in to comment.