From d9a07cc6894eb0fb62514613026d091f4318ce6a Mon Sep 17 00:00:00 2001 From: Rotem Rubnov Date: Tue, 19 May 2015 22:03:11 +0200 Subject: [PATCH 1/3] initialize JASwipeCell when loading the cell from NIB/Storyboard --- JASwipeCell/JASwipeCell.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/JASwipeCell/JASwipeCell.m b/JASwipeCell/JASwipeCell.m index 4c6744a..d783361 100644 --- a/JASwipeCell/JASwipeCell.m +++ b/JASwipeCell/JASwipeCell.m @@ -80,6 +80,12 @@ - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr return self; } +- (void) awakeFromNib +{ + [super awakeFromNib]; + [self initialize]; +} + - (void)initialize { [self addSubview:self.topContentView]; From 04da242a3f1f12bfa559f67fe4c7c9c6979b13b3 Mon Sep 17 00:00:00 2001 From: Rotem Rubnov Date: Tue, 19 May 2015 22:13:50 +0200 Subject: [PATCH 2/3] made all delegate methods optional --- JASwipeCell/JASwipeCell.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JASwipeCell/JASwipeCell.h b/JASwipeCell/JASwipeCell.h index 72ac813..4c78ed9 100644 --- a/JASwipeCell/JASwipeCell.h +++ b/JASwipeCell/JASwipeCell.h @@ -38,11 +38,11 @@ typedef NS_OPTIONS(NSUInteger, JAButtonLocation) { @class JASwipeCell; @protocol JASwipeCellDelegate +@optional // Called when the left most button has swiped all the way to the right. - (void)leftMostButtonSwipeCompleted:(JASwipeCell *)cell; // Called when the right most button has swiped all the way to the left. - (void)rightMostButtonSwipeCompleted:(JASwipeCell *)cell; -@optional // Called when the user begins swiping right on the cell. - (void)swipingRightForCell:(JASwipeCell *)cell; // Called when the user begins swiping left on the cell. From 1b342cbc6919da1e8144a5ee2d7aff80425166b0 Mon Sep 17 00:00:00 2001 From: Rotem Rubnov Date: Tue, 19 May 2015 22:27:46 +0200 Subject: [PATCH 3/3] added checks for optional delegate methods --- JASwipeCell/JASwipeCell.m | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/JASwipeCell/JASwipeCell.m b/JASwipeCell/JASwipeCell.m index d783361..d67b46a 100644 --- a/JASwipeCell/JASwipeCell.m +++ b/JASwipeCell/JASwipeCell.m @@ -441,7 +441,9 @@ - (void)panHandler:(UIPanGestureRecognizer *)recognizer [UIView animateWithDuration:0.1 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ [self pinButtonToTopViewWithOffset:newXOffset swipeDirection:JASwipeDirectionLeft]; } completion:^(BOOL finished) { - [self.delegate rightMostButtonSwipeCompleted:self]; + if ([self.delegate respondsToSelector:@selector(rightMostButtonSwipeCompleted:)]) { + [self.delegate rightMostButtonSwipeCompleted:self]; + } }]; self.rightButtonsRevealed = NO; } @@ -478,7 +480,9 @@ - (void)panHandler:(UIPanGestureRecognizer *)recognizer [UIView animateWithDuration:0.1 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ [self pinButtonToTopViewWithOffset:newXOffset swipeDirection:JASwipeDirectionRight]; } completion:^(BOOL finished) { - [self.delegate leftMostButtonSwipeCompleted:self]; + if ([self.delegate respondsToSelector:@selector(leftMostButtonSwipeCompleted:)]) { + [self.delegate leftMostButtonSwipeCompleted:self]; + } }]; self.leftButtonsRevealed = NO; }