可能重复:
remoteControlReceivedWithEvent in AVAudio is not being called
我正在尝试使用远程控制事件来启动/停止我的应用正在播放的某些音频,但是-remoteControlReceivedWithEvent:未被调用。我的应用程序有一个标签栏,可以在多个视图之间切换,如果这有任何不同。
每个视图的视图控制器使用远程控制事件实现每个Apple文档的设置(https://developer.apple.com/iphone/library/documentation/EventHandling/Conc eptual / EventHandlingiPhoneOS / REMOTECONTROL / RemoteControl.html#// apple_ref / d OC / UID / TP40009541-CH7-SW1)。我已将下面的这些位复制以供参考。
关于为什么-remoteControlReceivedWithEvent:没有被调用的任何想法?我应该在响应者链中的另一个对象上实现它吗?
史蒂夫
- (BOOL) canBecomeFirstResponder
{
return YES;
}
- (void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
}
- (void) viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[UIApplication sharedApplication] endReceivingRemoteControlEvents];
[self resignFirstResponder];
}