Location of UISwipeGestureRecognizer

I need to trigger another event depending on whether the user will iterate over the top of the screen, the middle of the screen or the bottom of the screen. I am trying to find the best / easiest way to do this, since I am sure there is no way to get the location from UISwipeGestureRecognizer.

The first option is to create my own scroll recognizer using touch methods. This seems like it would be very difficult (for example, trying to distinguish between swipe and drag).

The second option is to get the location from one of the β€œtouch” methods (for example, touchBegan) and somehow connect it using a swipe. Perhaps set a timer in touchhesBegan, and then if the recognition napkin is triggered within half a second or so, I find out that the napkins were associated with this touch.

The third possibility that I can think of is to lay 3 transparent peeps on top of my presentation and add a different napkin recognizer to each view. This seems like the best way to me, except that transparent views do not recognize touch / swipe events. So how can I get around this?

Any suggestions? Thanks.

+4
source share
2 answers

Perhaps you can use the locationOfTouch method for UISwipeGestureRecognizer.

CGPoint pt = [recognizer locationOfTouch:0 inView:view]; 

I believe this will give you the initial x, y coordinates of the touch that initiated the gesture.

+12
source

I used your third technique in one of my projects. Transparent DO views recognize swipe gestures. Here is the code I used, maybe you will forget something.

 -(id) initWithPageList:(id<PageListDisplayerDelegate>) iDelegate { self = [super init]; if (self) { // Custom initialization self.delegate = iDelegate; UISwipeGestureRecognizer* swipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(viewSwiped:)]; swipeRecognizer.direction = UISwipeGestureRecognizerDirectionRight | UISwipeGestureRecognizerDirectionLeft; [self.view addGestureRecognizer:swipeRecognizer]; [swipeRecognizer release]; } return self; 

}

 -(void) viewSwiped:(UISwipeGestureRecognizer*) sender { NSLog(@"View Swiped"); } 
0
source

All Articles