0

I got an error. "No visible interface for UISwipeGestureRecognizer declares the selector 'touchesMoved:withEvent:'"

I looked at documentation and found touchesMoved:withEvent at UIGestureRecognizer class. How do I solve this error?

@interface MySwipeRecognizer : UISwipeGestureRecognizer

@implementation MySwipeRecognizer

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
 [super touchesMoved:touches withEvent:event];
}
@end
Voloda2
  • 12,359
  • 18
  • 80
  • 130

1 Answers1

1

Unless I'm misunderstanding the question, a UISwipeGestureRecognizer does all the touch handling for you. Your code would look something like this:

UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(onSwipe:)];

// set a direction for the swipe
[swipe setDirection:UISwipeGestureRecognizerDirectionLeft];

// self is a view to add the recognizer to:
[self addGestureRecognizer:swipe];

.
.
.

- (void) onSwipe:(id)sender
{
 // a swipe has been recognized!
}

UIGestureRecognizer is an ABSTRACT class, so concrete implementations like UISwipeGestureRecognizer do all the touch event handling for you. If you're trying to create your own custom gesture recognizer, you'd subclass UIGestureRecognizer.

CSmith
  • 13,318
  • 3
  • 39
  • 42
  • I want to know 3 events: user touch begin, user touch end, and swipe. Ok, I'll try to subclass UIGestureRecognizer. – Voloda2 Sep 24 '12 at 21:35