title: Subclassing UIPanGestureRecognizer to wait for Condition before recognition
body: <p>I'm trying to link two gestures one after another. UILongPressGestureRecognizer, then UIPanGestureRecognizer.</p>
  
  <p>I want to detect the Long Press, then allow the Pan gesture to be recognized. </p>
  
  <p>I've Subclassed UIPanGestureRecognizer and Added an panEnabled Bool iVar.  In the initWith Frame I've set panEnabled to NO. </p>
  
  <p>In Touches Moved I check to see if it is enabled, and then call Super touchesMoved if it is.</p>
  
  <p>In my LongPress Gesture Handler, I loop though the View's Gestures till I find my Subclassed Gesture and then setPanEnabled to YES. </p>
  
  <p>It seems like it is working, though its like the original pan gesture recognizer is not functioning properly and not setting the Proper states. I know if you Subclass the UIGestureRecognizer, you need to maintain the state yourself, but I would think that if you are subclassing UIPanGestureRecognizer, and for all the touches methods calling the super, that it would be setting the state in there. </p>
  
  <p>Here is my subclass .h File</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  #import &lt;UIKit/UIGestureRecognizerSubclass.h&gt;
  
  @interface IoUISEListPanGestureRecognizer : UIPanGestureRecognizer {
      int IoUISEdebug;
      BOOL panEnabled;    
  }
  - (id)initWithTarget:(id)target action:(SEL)action;
  @property(nonatomic, assign) int IoUISEdebug;
  @property(nonatomic, assign) BOOL panEnabled;
  
  @end
  </code></pre>
  
  <p>here is the subclass .m File</p>
  
  <pre><code>#import "IoUISEListPanGestureRecognizer.h"
  
  @implementation IoUISEListPanGestureRecognizer
  @synthesize IoUISEdebug;
  @synthesize panEnabled;
  
  - (id)initWithTarget:(id)target action:(SEL)action {
      [super initWithTarget:target action:action];
      panEnabled = NO;
      return self;
  }
  
  - (void)ignoreTouch:(UITouch*)touch forEvent:(UIEvent*)event {
      [super ignoreTouch:touch forEvent:event];
  }
  
  -(void)reset {
      [super reset];
      panEnabled = NO;
  }
  
  - (BOOL)canPreventGestureRecognizer:(UIGestureRecognizer *)preventedGestureRecognizer {  
      return [super canPreventGestureRecognizer:preventedGestureRecognizer];
  }
  
  - (BOOL)canBePreventedByGestureRecognizer:(UIGestureRecognizer *)preventingGestureRecognizer{
      return [super canBePreventedByGestureRecognizer:preventingGestureRecognizer];
  }
  
  - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
      [super touchesBegan:touches withEvent:event];
  }
  
  - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
      if (panEnabled) {
          [super touchesMoved:touches withEvent:event];
      }
  }
  
  - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
      [super touchesEnded:touches withEvent:event];    
  }
  
  - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{
      [super touchesCancelled:touches withEvent:event];
  }
  @end
  </code></pre>