mutualmobile / MMDrawerController

A lightweight, easy to use, Side Drawer Navigation Controller
MIT License
6.76k stars 1.38k forks source link

Enable swipe to delete in centreViewController #275

Open GaryHomewood opened 10 years ago

GaryHomewood commented 10 years ago

I am trying to to allow swipe left to delete for a table view in the centre view controller.

I am implementing the UIGestureRecognizerDelegate and I have the following, which only works occasionally:

override func viewDidLoad() {
    var swipe = UISwipeGestureRecognizer()
    swipe.delegate = self
    self.tableView.addGestureRecognizer(swipe)
}

func gestureRecognizer(gestureRecognizer: UIGestureRecognizer!, shouldRecognizeSimultaneouslyWithGestureRecognizer otherGestureRecognizer: UIGestureRecognizer!) -> Bool {
    return true
}

Any ideas?

alexmilde commented 10 years ago

hey. just ran into this problem. check this property. maybe it helps.

[drawerController setOpenDrawerGestureModeMask:MMOpenDrawerGestureModePanningNavigationBar]

michalvantuch commented 10 years ago

I've tried both, but it doesn't seem to work.

jonasman commented 9 years ago

+1 any clean solution for this?

jonasman commented 9 years ago

I found a solution for this:

Will work for those who only use LEFT pane and Center Pane.

 [[self.navigationController mm_drawerController] setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeCustom];
 __weak typeof(self)weakSelf = self;

[[self.navigationController mm_drawerController] setGestureShouldRecognizeTouchBlock:^BOOL(MMDrawerController *drawerController, UIGestureRecognizer *gesture, UITouch *touch) {

    if ([gesture isKindOfClass:[UIPanGestureRecognizer class]])
    {
        BOOL myView = [weakSelf checkSelfSuperview:touch.view];

        if (myView)
        {
            return NO;
        }
    }

    return YES;

}];

- (BOOL)checkSelfSuperview:(UIView *)view
{
    if (view == self.view)
       return YES;
    else if (view.superview == nil)
       return NO;
    else
   {
        return [self checkSelfSuperview:view.superview];
   }    
}
mark22 commented 7 years ago

@jonasman Jonas, From a newbie, where do you place those two pieces of code? Desperate to find a fix to this.

Thank you!!

jonasman commented 7 years ago

@mark22 this was 2 years ago. I guess you need to add this to some viewcontroller that uses the lib. Maybe some root VC