Reputation: 3519
I call a method in the touchesEnded method called addProjectile. addProjectile receives the NSSet of touches that the touchesEnded method receives. For simplicity, I've only posted the relevant code to my question. So, just to be clear:
-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
[self addProjectile:touches]; }
-(void) addProjectile:(NSSet *)touches {//do stuff }
I would like to call addProjectile at the end of a UIPanGestureRecognizer method called swipeRight and send the correct NSSet of touches.
-(void)swipedRight:(UIPanGestureRecognizer *)recognizer {
CGPoint panned=[recognizer translationInView:self.view];
if(panned.x>50){//do stuff }
else {
NSSet *touches; <-- this is what I need to get
[self addProjectile:touches];
So my question is how do I get the correct NSSet of touches (which would be where the user picked up his/her finger) at the end of swipedRight: to perform the addProjectile method correctly.
Upvotes: 1
Views: 1906
Reputation: 4271
Have a look at UIGestureRecognizerState
. That is what you need.
Sample code (assumption here being, you only need the touch point when the user finishes panning i.e. lifts his finger):
-(void)swipedRight:(UIPanGestureRecognizer *)panGesture {
if ([panGesture state] == UIGestureRecognizerStateEnded) {
//User touch has ended
CGPoint touchUpPoint = [panGesture translationInView:self.view]; // or `locationInView:`
NSLog(@"__TOUCH_END_POINT__ = %@", NSStringFromCGPoint(touchUpPoint));
}
}
Upvotes: 7