在.plist中,我添加了正常的:http://tinyurl.com/c7e9joy 當iPhone被鎖定或我在應用程序之外並打開遠程按鈕時,我可以在那裏看到應用程序徽標和標題,但它們不要反應。 (我測試我自己的iPhone。)iOS remoteControlReceivedWithEvent不叫
// 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;
}
}
}
改變了它,但仍然沒有效果,它似乎沒有抓住事件。 – Miko