在 .plist 中,我添加了正常的:http ://tinyurl.com/c7e9joy 当 iPhone 被锁定或我在应用程序之外并打开远程按钮时,我可以在那里看到应用程序徽标和标题,但它们不要反应。(我正在我自己的 iPhone 上进行测试。)
// Makes sure we are able to connect to the media buttons on the lock screen.
- (BOOL) canBecomeFirstResponder
{
return YES;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
}
- (void) remoteControlReceivedWithEvent: (UIEvent *) receivedEvent {
NSLog(@"REMOTE");
if (receivedEvent.type == UIEventTypeRemoteControl) {
switch (receivedEvent.subtype) {
case UIEventSubtypeRemoteControlTogglePlayPause:
[self playBtnPressed:nil];
break;
case UIEventSubtypeRemoteControlPreviousTrack:
[self skipTrack:nil];
break;
case UIEventSubtypeRemoteControlNextTrack:
[self skipTrack:nil];
break;
default:
break;
}
}
}