diff --git a/SWTableViewCell/PodFiles/SWTableViewCell.m b/SWTableViewCell/PodFiles/SWTableViewCell.m index df277a6..989e29e 100644 --- a/SWTableViewCell/PodFiles/SWTableViewCell.m +++ b/SWTableViewCell/PodFiles/SWTableViewCell.m @@ -137,6 +137,8 @@ - (void)initializer { [self.scrollViewContentView addSubview:subview]; } + + self.containingTableView.directionalLockEnabled = YES; } - (void)layoutSubviews @@ -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; } @@ -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 @@ -566,7 +570,6 @@ - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView self.tapGestureRecognizer.enabled = YES; if (_cellState == kCellStateCenter) { - self.containingTableView.scrollEnabled = YES; self.longPressGestureRecognizer.enabled = YES; } }