Search code examples
iosiphoneobjective-cdragpopover

iphone sdk: how to distinguish between touch and drag


i am using 2 pods.

MMDrawerController 0.5.1& WYPopoverController 0.1.7

now i want to make a WYPopover on my MMView

some pics:

this is how the MMController looks like (Playground)

some playground

now i want to touch it anywhere and make it look like:

normal when touched

the error: if i want to open the left view from the 'MMController' sometimes i get this:

the error

but it should look like (left MMControllerView)

enter image description here

i am using the 2 methods:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
// show the popoverController
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    [popController dismissPopoverAnimated:NO];
}

my question: why the touchesMoved isn't called continuous and if there is a better way?


Solution

  • I don't know anything about the "pods" you mention (CocoaPods?) However, the most straightforward way to distinguish between taps and drags is to use a pair of gesture recognizers, a tap gesture recognizer and a pan gesture recognizer, and set up the tap gesture recognizer so the pan gesture must fail before the tap is triggered (There is a "wait until another gesture recognizer fails" mechanism built into gesture recognizers.)

    I suggest reading up on UIGestureRecognizer, and the specific classes UITapGestureRecognizer and UIPanGestureRecognizer