John-Lluch / SWRevealViewController

A UIViewController subclass for presenting side view controllers inspired on the FaceBook and Wunderlist apps, done right !
Other
4.52k stars 987 forks source link

Problem when closing with finger #699

Closed jrbecart closed 7 years ago

jrbecart commented 7 years ago

If I open the menu with the icon (top left) and close the drawer with gesture (right to left), I can't scroll the page and when I remove my finger from the screen the drawer open again. Dis somebody notice that before?

iDevelopper commented 7 years ago

Could you elaborate please? What scroll? Pan gesture right to left is designed to close rear view. If rear view open again, it is because your pan length is not enough.

jrbecart commented 7 years ago

In the image below: 1: I touch the hamburger icon to open the menu. (It works) 2: I close the menu with gesture. (It works) 3: After I touch the screen (or slide or scroll) the menu open again.(My problem) 4: Menu is opening again.

image

If I want to close the menu properly I have to touch the hamburger icon or touch outside the menu. If open the menu with gesture, I can close it with gesture.(It works)

iDevelopper commented 7 years ago

ave you implemented some delegate method?

jrbecart commented 7 years ago

Yes I have some delegate method.

iDevelopper commented 7 years ago

Okay, what are they doing?

jrbecart commented 7 years ago

I manage notifications, I have utility method and also I have authentication method. (firebase based)

iDevelopper commented 7 years ago

You could add a SW delegate method to allow open the menu by panning from the border of the screen like this:

- (BOOL)revealControllerPanGestureShouldBegin:(SWRevealViewController *)revealController {
    CGPoint point = [revealController.panGestureRecognizer locationInView:self.view];
    // Menu is close, pan gesture should begin if pan start from border
    if (revealController.frontViewPosition == FrontViewPositionLeft && point.x < 50.0) {
        return YES;
    }
    // Menu is open, pan gesture should begin
    else if (revealController.frontViewPosition == FrontViewPositionRight) {
        return YES;
    }
    return NO;
}
jrbecart commented 7 years ago

Thank you @iDevelopper, I tried this but it doesn't help, also for information my view is a uiwebview. It seems to works if it's not a uiwebview...

iDevelopper commented 7 years ago

Ok then you have to implement also:

- (BOOL)revealController:(SWRevealViewController *)revealController panGestureRecognizerShouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    return YES;
}
iDevelopper commented 7 years ago

I did not remember but you have also a property in SW named draggableBorderWidth which you can use instead of the delegate method:

self.revealViewController.draggableBorderWidth = 50;
jrbecart commented 7 years ago

It's much better! I can open & close with panGesture. I can open & close with tapGesture. I can't mix tapGesture and panGesture, like open with panGesture and close with tapGesture. I'm ok with your solutions, thank you.