Skip to content

Commit

Permalink
Enable swipe to delete on cells
Browse files Browse the repository at this point in the history
Beginning to swipe to the right triggers the menu to open while swiping
to the left will trigger the table's swipe to delete.
  • Loading branch information
enriquez committed Dec 14, 2013
1 parent 41fc21a commit 6780728
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Expand Up @@ -24,6 +24,6 @@
#import <UIKit/UIKit.h>
#import "ECSlidingViewController.h"

@interface METransitionsViewController : UITableViewController <ECSlidingViewControllerDelegate>
@interface METransitionsViewController : UITableViewController <ECSlidingViewControllerDelegate, UIGestureRecognizerDelegate>
- (IBAction)menuButtonTapped:(id)sender;
@end
17 changes: 17 additions & 0 deletions Examples/TransitionFun/TransitionFun/METransitionsViewController.m
Expand Up @@ -42,6 +42,7 @@ - (void)viewDidLoad {
self.clearsSelectionOnViewWillAppear = NO;

self.transitions.dynamicTransition.slidingViewController = self.slidingViewController;
self.slidingViewController.panGesture.delegate = self;

dispatch_async(dispatch_get_main_queue(), ^{
NSIndexPath *defaultIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];
Expand Down Expand Up @@ -69,6 +70,7 @@ - (UIPanGestureRecognizer *)dynamicTransitionPanGesture {
if (_dynamicTransitionPanGesture) return _dynamicTransitionPanGesture;

_dynamicTransitionPanGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self.transitions.dynamicTransition action:@selector(handlePanGesture:)];
_dynamicTransitionPanGesture.delegate = self;

return _dynamicTransitionPanGesture;
}
Expand Down Expand Up @@ -119,6 +121,21 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
}
}

-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{

}

#pragma mark - UIGestureRecognizerDelegate

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
if ([otherGestureRecognizer.view isKindOfClass:[UIScrollView class]]) {
return YES;
} else {
return NO;
}
}


- (IBAction)menuButtonTapped:(id)sender {
[self.slidingViewController anchorTopViewToRightAnimated:YES];
}
Expand Down

0 comments on commit 6780728

Please sign in to comment.