I am working on a simple note taking / drawing application. I have a view controller that works like paper / canvas. In it, I want to implement a UISwipeGestureRecognizer, for example, when a user quickly wants to show a menu that he or she can move up, instead of pressing the "change" button, or maybe scroll left or right when he / she wants to change paper / note.
The problem is that when the user tries (with two fingers), the application also draws a short line in the same direction.
I implemented UISwipeGestureRecognizer as follows:
UISwipeGestureRecognizer *recognizer; recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)]; [recognizer setDirection:(UISwipeGestureRecognizerDirectionUp)]; recognizer.numberOfTouchesRequired = 2; [[self view] addGestureRecognizer:recognizer]; [recognizer release];
The painting mechanism is processed in one controller in the following ways:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
It seems that the three methods above are being called before my UIGestureRecognizer. I tried to create a BOOL variable and disable the drawing code if the boolean variable is YES. But that did not work. Any other ideas on how to solve this problem would be great!
Note. I am testing napkins in a simulator. Maybe this affects it?
source share