Skip to content

Commit b5b2a92

Browse files
committed
Merge pull request CEWendel#52 from onevcat/master
Add -swipeableTableViewCell:canSwipeToState: delegate
2 parents 1650121 + 5bd59c4 commit b5b2a92

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

SWTableViewCell/PodFiles/SWTableViewCell.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ typedef enum {
2828
- (void)swipeableTableViewCell:(SWTableViewCell *)cell didTriggerLeftUtilityButtonWithIndex:(NSInteger)index;
2929
- (void)swipeableTableViewCell:(SWTableViewCell *)cell didTriggerRightUtilityButtonWithIndex:(NSInteger)index;
3030
- (void)swipeableTableViewCell:(SWTableViewCell *)cell scrollingToState:(SWCellState)state;
31-
31+
- (BOOL)swipeableTableViewCell:(SWTableViewCell *)cell canSwipeToState:(SWCellState)state;
3232
@end
3333

3434
@interface SWTableViewCell : UITableViewCell

SWTableViewCell/PodFiles/SWTableViewCell.m

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,14 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView
508508
{
509509
if ([self rightUtilityButtonsWidth] > 0)
510510
{
511+
if (self.delegate && [self.delegate respondsToSelector:@selector(swipeableTableViewCell:canSwipeToState:)])
512+
{
513+
scrollView.scrollEnabled = [self.delegate swipeableTableViewCell:self canSwipeToState:kCellStateRight];
514+
if (!scrollView.scrollEnabled)
515+
{
516+
return;
517+
}
518+
}
511519
CGFloat scrollViewWidth = MIN(scrollView.contentOffset.x - [self leftUtilityButtonsWidth], [self rightUtilityButtonsWidth]);
512520

513521
// Expose the right button view
@@ -523,6 +531,14 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView
523531
// Expose the left button view
524532
if ([self leftUtilityButtonsWidth] > 0)
525533
{
534+
if (self.delegate && [self.delegate respondsToSelector:@selector(swipeableTableViewCell:canSwipeToState:)])
535+
{
536+
scrollView.scrollEnabled = [self.delegate swipeableTableViewCell:self canSwipeToState:kCellStateLeft];
537+
if (!scrollView.scrollEnabled)
538+
{
539+
return;
540+
}
541+
}
526542
CGFloat scrollViewWidth = MIN(scrollView.contentOffset.x - [self leftUtilityButtonsWidth], [self leftUtilityButtonsWidth]);
527543

528544
self.scrollViewButtonViewLeft.frame = CGRectMake([self leftUtilityButtonsWidth], 0.0f, scrollViewWidth, self.height);

0 commit comments

Comments
 (0)