From e05909ca12b340a5dc9b19fb3a6cf0363b752493 Mon Sep 17 00:00:00 2001 From: Charlie Wu Date: Sun, 13 Apr 2014 09:48:35 +1000 Subject: [PATCH] disable left or right swipe base on imageSet --- JZSwipeCell/JZSwipeCell.m | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/JZSwipeCell/JZSwipeCell.m b/JZSwipeCell/JZSwipeCell.m index 021c622..1214c82 100644 --- a/JZSwipeCell/JZSwipeCell.m +++ b/JZSwipeCell/JZSwipeCell.m @@ -161,6 +161,9 @@ - (SwipeCellColorSet*)defaultColorSet - (void)gestureHappened:(UIPanGestureRecognizer *)sender { CGPoint translatedPoint = [sender translationInView:self]; + if (translatedPoint.x > 0 && !self.allowSwipeRight) return; + if (translatedPoint.x < 0 && !self.allowSwipeLeft) return; + switch (sender.state) { case UIGestureRecognizerStatePossible: @@ -351,6 +354,16 @@ - (BOOL)isLeftSwipeType:(JZSwipeType)type return type == JZSwipeTypeShortLeft || type == JZSwipeTypeLongLeft; } +- (BOOL)allowSwipeRight +{ + return (self.imageSet.longRightSwipeImage || self.imageSet.shortRightSwipeImage); +} + +- (BOOL)allowSwipeLeft +{ + return (self.imageSet.longLeftSwipeImage || self.imageSet.shortLeftSwipeImage); +} + @end @implementation SwipeCellImageSet