title: Detect headset button press
body: <p>I need to utilize the headset button press for something other than multimedia on my app.  Here's what I have so far and it's not working.  When I press the headset button, my app does not respond, instead music plays...</p>
  
  <pre><code>- (BOOL)canBecomeFirstResponder {
  
  return YES;
  }
  
  - (void)viewDidAppear:(BOOL)animated {
  
  [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
  if ([self canBecomeFirstResponder]) {
      [self becomeFirstResponder];
      NSLog(@"became first responder");
  }
  
  }
  
   - (void)remoteControlReceivedWithEvent:(UIEvent *)theEvent
   {
  if (theEvent.type == UIEventTypeRemoteControl) {
      switch(theEvent.subtype) {
          case UIEventSubtypeRemoteControlTogglePlayPause:
              NSLog(@"Hello");
  
          case UIEventSubtypeRemoteControlPlay:
              NSLog(@"Hello 2");
              break;
          case UIEventSubtypeRemoteControlPause:
              NSLog(@"Hello 3");
              break;
          case UIEventSubtypeRemoteControlStop:
              NSLog(@"Hello 4");
              break;
          default:
              return;
      }
  }
   }
  </code></pre>