Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird edge case issue with DrawerGestureModePanning #25

Merged
merged 7 commits into from
Jul 22, 2013

Conversation

kcharwood
Copy link
Contributor

Our case is we have a central view, that uses a custom navigation bar, and not a standard navigation controller. So by appearances, there looks to be a navigation bar on screen.

Our central view has a drawing/annotating element, so needs to listen to touch events, which the center panning mode is eating up.

If I set the open/close drawer mask to MMOpenDrawerGestureModePanningNavigationBar, the center basically goes dead.

There is a redesign of the center controller's UI underway, but any alternatives in the meantime?

@kcharwood
Copy link
Contributor

I've thought about providing a callback block to let a implementor determine if that touch should be recognized for a specific gesture...

I'll see if I have time to throw something together this week.

BTW - > Use a UINavigationController :)

@kcharwood
Copy link
Contributor

Put together a potential solution here: 940989c

@kcharwood
Copy link
Contributor

@larsacus need eyes on that as well.

@kcharwood
Copy link
Contributor

Resolved merge with c35a65b

Conflicts:
	MMDrawerController/MMDrawerController.h
	MMDrawerController/MMDrawerController.m
@kcharwood
Copy link
Contributor

@danmurrelljr Let me know if you think that would solve your problem.

@yfujiki
Copy link

yfujiki commented Jul 10, 2013

Wouldn't it be more flexible to let users register "allowed" gesture recognizers? There may be several screens in the project that require different gesture recognizers to work.

@kcharwood
Copy link
Contributor

Hey @yfujiki,

In that case, you could have each view controller reset that block to define the behavior that they want...

When you say "register allowed gesture recognizers", what did you have in mind?

@yfujiki
Copy link

yfujiki commented Jul 10, 2013

@kcharwood

What I had in mind was that MMDrawerController will have addAllowedGestureRecognizer: method, and whenever the potential gestureRecognizer matches the internally stored allowedGestureRecognizers set, it delegates the touch.

But I think your suggestion simply works, as long as I reset the block in viewDidAppear or viewWillAppear. Drawback of my suggested approach is that user can stack up a lot of gesture recognizers, which is not very good. The reason I thought of the approach is that I am not trusting the consistency of ...Appear callbacks very much esp. depending on the OS version... viewDidLoad is more consistent, I feel.

But at least, isn't it better to allow multiple gesture recognizers in the block parameter? In my situation, I have left/right swipe gesture recognizers, and the swipe recognizers seem to conflict. Hypothetically, a view can consist of several subviews that have different pan gesture recognizers as well.

@kcharwood
Copy link
Contributor

@yfujiki

For your last point, you actually dont need multiple pan gesture recognizers. You can simply take the touch point, inspect your view, and determine if that gesture should be recognized.

We're looking at trying to roll this out soon.

@yfujiki
Copy link

yfujiki commented Jul 16, 2013

@kcharwood https://github.com/kcharwood

That is true. Although it introduces a little bit of constraints of coding
(you can not use individual gesture recognizer if you want), I can live
with that.
But that doesn't cover my left/right swipe gestures case though. They are
in the same view, and can be any point. Any suggestion?

On Tue, Jul 16, 2013 at 3:44 PM, Kevin Harwood notifications@github.comwrote:

@yfujiki https://github.com/yfujiki

For your last point, you actually dont need multiple pan gesture
recognizers. You can simply take the touch point, inspect your view, and
determine if that gesture should be recognized.

We're looking at trying to roll this out soon.


Reply to this email directly or view it on GitHubhttps://github.com//pull/25#issuecomment-21072178
.

@kcharwood
Copy link
Contributor

@yfujiki I'm not sure I am trying to solve the swipe gesture use case. The swipe gesture seems a bit out of place since the swipe gesture requires the gesture to complete before its callback happens, while the pan gesture gives the user immediate feedback and allows them to manipulate the screen directly.

You should be able to add swipe gestures to your view controllers and just manually call to open/close the drawer when they occur.

@jonasman
Copy link

Hi guys,

I have been using the inferis View Deck lib and now im converting to yours. This one looks better and cleaner.

In View Deck this problem does not exist. The pan gesture to open another VC is only activated if the views in front has no gestures recognisers. for Ex: a delete movement in a cell will not trigger the pan

@kcharwood
Copy link
Contributor

Hey @jonasman,

Thanks for the comments. This library is actually a bit cleaner due to how we handle the gestures, so I don't think it would be trivial to migrate to the ViewDeck approach.

For all in this thread, here is an example of how this approach could be used:

[myDrawerController setOpenGestureModeMask:MMOpenDrawerGestureModeCustom];
[myDrawerController
 setGestureShouldRecognizeTouchBlock:^BOOL(MMDrawerController *drawerController, UIGestureRecognizer *gesture, UITouch *touch) {
     BOOL shouldRecognizeTouch = NO;
     if(drawerController.openSide == MMDrawerSideNone &&
        [gesture isKindOfClass:[UIPanGestureRecognizer class]]){
         UIView * customView = [drawerController.centerViewController myCustomSubview];
         CGPoint location = [touch locationInView:customView];
         shouldRecognizeTouch = (CGRectContainsPoint(customView.bounds, location));
     }
     return shouldRecognizeTouch;
 }];

I'll leave this thread open for comment for another day or two before tying it off and shipping 0.3.0.

kcharwood added a commit that referenced this pull request Jul 22, 2013
Weird edge case issue with DrawerGestureModePanning
@kcharwood kcharwood merged commit a4e812c into master Jul 22, 2013
@kcharwood
Copy link
Contributor

I'll be shipping this in 0.3.0 today.

@kylebrowning
Copy link

@kcharwood Im attempting to use setGestureShouldRecognizeTouchBlock.

Im just putting in a return NO; and my drawer controller is still panning.

I have a uiSwitch in the center of my CenterViewController that I basically can't turn on or off because it wants to pan.

Any ideas?

@kylebrowning
Copy link

I figured it out, I was resetting the Custom Pan Mode to Bezel by mistake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants