diff --git a/MGSwipeTableCell/MGSwipeTableCell.h b/MGSwipeTableCell/MGSwipeTableCell.h index c1c8ab2..f81fa1d 100644 --- a/MGSwipeTableCell/MGSwipeTableCell.h +++ b/MGSwipeTableCell/MGSwipeTableCell.h @@ -168,6 +168,8 @@ typedef NS_ENUM(NSInteger, MGSwipeExpansionLayout) { @property (nonatomic) BOOL allowsButtonsWithDifferentWidth; //default is YES. Controls wheter swipe gesture is allowed when the touch starts into the swiped buttons @property (nonatomic) BOOL allowsSwipeWhenTappingButtons; +// default is NO. Controls whether the cell selection/highlight status is preserved when expansion occurs +@property (nonatomic) BOOL preservesSelectionStatus; /** Optional background color for swipe overlay. If not set, its inferred automatically from the cell contentView */ @property (nonatomic, strong) UIColor * swipeBackgroundColor; diff --git a/MGSwipeTableCell/MGSwipeTableCell.m b/MGSwipeTableCell/MGSwipeTableCell.m index f45e809..b22788d 100644 --- a/MGSwipeTableCell/MGSwipeTableCell.m +++ b/MGSwipeTableCell/MGSwipeTableCell.m @@ -484,6 +484,7 @@ -(void) initViews: (BOOL) cleanButtons _swipeState = MGSwipeStateNone; _triggerStateChanges = YES; _allowsSwipeWhenTappingButtons = YES; + _preservesSelectionStatus = NO; } -(void) cleanViews @@ -578,7 +579,8 @@ - (void) showSwipeOverlayIfNeeded } _overlayEnabled = YES; - self.selected = NO; + if (!_preservesSelectionStatus) + self.selected = NO; if (_swipeContentView) [_swipeContentView removeFromSuperview]; _swipeView.image = [self imageFromView:self]; @@ -983,7 +985,8 @@ -(void) panHandler: (UIPanGestureRecognizer *)gesture CGPoint current = [gesture translationInView:self]; if (gesture.state == UIGestureRecognizerStateBegan) { - self.highlighted = NO; + if (!_preservesSelectionStatus) + self.highlighted = NO; [self createSwipeViewIfNeeded]; _panStartPoint = current; _panStartOffset = _swipeOffset;