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. diff --git a/JASwipeCell/JASwipeCell.m b/JASwipeCell/JASwipeCell.m index 4c6744a..d67b46a 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]; @@ -435,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; } @@ -472,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; }