I want a single view application, where I detect a middle button click of my original iPhone headphone.
I tried with
- (void)remoteControlReceivedWithEvent:(UIEvent *)theEvent
{
if (theEvent.type == UIEventTypeRemoteControl) {
switch(theEvent.subtype) {
case UIEventSubtypeRemoteControlTogglePlayPause:
//Insert code
case UIEventSubtypeRemoteControlPlay:
//Insert code
break;
case UIEventSubtypeRemoteControlPause:
// Insert code
break;
case UIEventSubtypeRemoteControlStop:
//Insert code.
break;
default:
return;
}
}
}
and
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
}
and
- (BOOL) canBecomeFirstResponder {
return YES;
}
But no chance :( There are no catchable events.
Does anyone have an idea?