m1entus / MZFormSheetPresentationController

MZFormSheetPresentationController provides an alternative to the native iOS UIModalPresentationFormSheet, adding support for iPhone and additional opportunities to setup UIPresentationController size and feel form sheet.
MIT License
973 stars 146 forks source link

#58 hotfix #70

Closed Nonepse closed 8 years ago

Nonepse commented 8 years ago

https://github.com/m1entus/MZFormSheetPresentationController/issues/58

I don't think it's necessary to disable the recognizer if shouldFailGestureRecognizerForDismissDirection:location:presentingView: returns YES.

As per Apple documentation:

If you change this property to NO while a gesture recognizer is currently recognizing a gesture, the gesture recognizer transitions to a cancelled state.

A recognizer in a cancelled state is not handled by handleEdgeDismissalPanGestureRecognizer:dismissDirection:forPresentingView:fromViewController:

m1entus commented 8 years ago

Tahnks. I think that better option would be to add just Cancelled and Failed state and handle it calling [self cancelInteractiveTransition];, this would be safer for future purpose.

Nonepse commented 8 years ago

That's actually what I tried first, but it doesn't seem to work. Am I missing something?

m1entus commented 8 years ago

Have you tried to recognier.enabled = NO, then [self cancelInteractiveTransition]; and recognizer.enabled = YES, and additionally handle Cancel, and Failure states ?

Nonepse commented 8 years ago

The following code doesn't fix the bug.

if (recognizer.state == UIGestureRecognizerStateFailed || recognizer.state == UIGestureRecognizerStateCancelled) {
    [self cancelInteractiveTransition];
} else if (recognizer.state == UIGestureRecognizerStateBegan) {
    if ([self shouldFailGestureRecognizerForDismissDirection:dismissDirection location:location presentingView:presentingView]) {
        recognizer.enabled = NO;
        [self cancelInteractiveTransition];
        recognizer.enabled = YES;
        return;
    }

    self.panGestureRecognizerStartLocation = location;
    self.sourceViewInitialFrame = presentingView.frame;
    [viewController dismissViewControllerAnimated:YES completion:nil];
}

Is that what you meant?

m1entus commented 8 years ago

Hmm okay, i will merge this and i hope that this will not break something else, i forgot i failing recognizer is necessary.

Thanks anyway!.