【问题标题】:remoteControlReceivedWithEvent method [duplicate]remoteControlReceivedWithEvent 方法[重复]
【发布时间】:2011-10-09 02:58:57
【问题描述】:

可能重复:
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];
}

【问题讨论】:

    标签: iphone stack stack-overflow


    【解决方案1】:

    您是否将 UIBackgroundModes 音频键添加到 info.plist?请参阅docs。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-31
      • 1970-01-01
      • 2011-12-14
      • 2021-05-20
      相关资源
      最近更新 更多