Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Jay's right... you'll want a subclass. Try this one for size, it's from one of my projects. In DragGestureRecognizer.h:</p> <pre><code>@interface DragGestureRecognizer : UILongPressGestureRecognizer { } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; @end @protocol DragGestureRecognizerDelegate &lt;UIGestureRecognizerDelegate&gt; - (void) gestureRecognizer:(UIGestureRecognizer *)gr movedWithTouches:(NSSet*)touches andEvent:(UIEvent *)event; @end </code></pre> <p>And in DragGestureRecognizer.m:</p> <pre><code>#import "DragGestureRecognizer.h" @implementation DragGestureRecognizer - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { [super touchesMoved:touches withEvent:event]; if ([self.delegate respondsToSelector:@selector(gestureRecognizer:movedWithTouches:andEvent:)]) { [(id)self.delegate gestureRecognizer:self movedWithTouches:touches andEvent:event]; } } @end </code></pre> <p>Of course, you'll need to implement the </p> <pre><code>- (void) gestureRecognizer:(UIGestureRecognizer *)gr movedWithTouches:(NSSet*)touches andEvent:(UIEvent *)event; </code></pre> <p>method in your delegate -- for example:</p> <pre><code>DragGestureRecognizer * gr = [[DragGestureRecognizer alloc] initWithTarget:self action:@selector(pressed:)]; gr.minimumPressDuration = 0.15; gr.delegate = self; [self.view addGestureRecognizer:gr]; [gr release]; - (void) gestureRecognizer:(UIGestureRecognizer *)gr movedWithTouches:(NSSet*)touches andEvent:(UIEvent *)event{ UITouch * touch = [touches anyObject]; self.mTouchPoint = [touch locationInView:self.view]; self.mFingerCount = [touches count]; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload