title: how UILongPressGestureRecognizer works
body: <p>I am trying to understand how the gesture recognizer works and trying to get a gesture recognizer to tell me when a long touch BEGINS and when it ENDS even if the touch does not move.</p>
  
  <p>In <code>viewDidLoad</code>, I add a subview called game.
  In game, I have implemented two ways to recognize touches. One works but does not do what I want. The other does not work.</p>
  
  <p><strong>Method1</strong> I just added two methods:   </p>
  
  <pre><code>- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
      NSLog(@"Began");
  }
  
  - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *) event {
      NSLog(@"Ended");
  }
  </code></pre>
  
  <p>This worked, without instantiating a gesture recognizer. Can someone tell me why?</p>
  
  <p>The issue with this is that <code>- (void)touchedEnded:</code> only gets called if the touch moved and not if the touch ended at the same location it started.   So if I touched and moved and let go, both functions get called. If I touch and hold and let go (without moving), only the <code>- (void)touchesBegan</code> gets called.</p>
  
  <p><strong>METHOD 2</strong>
  I instantiated a gesture recognizer:</p>
  
  <pre><code>@property (nonatomic, strong) UILongPressGestureRecognizer *lprg;
  </code></pre>
  
  <p>then in my setup:</p>
  
  <pre><code>self.lprg = [UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];
  </code></pre>
  
  <p>then:</p>
  
  <pre><code>- (void)handleLongPress:(UILongPressGestureRecognizer *)recognizer {
      NSLog(@"Handling");
      switch (recognizer.state) {
       case UIGestureRecognizerStateBegan:
           // ...
      }
  }
  </code></pre>
  
  <p>But this one, where I programmatically instantiated the recognizer, did not work. I never got any NSLog output in the console.</p>