Ios5 remoteControlReceivedWithEvent未在多视图控制器应用程序中调用

Ios5 remoteControlReceivedWithEvent未在多视图控制器应用程序中调用,ios5,avaudioplayer,remote-control,Ios5,Avaudioplayer,Remote Control,我有一个应用程序在iOS 4.3.3上运行良好。但是我发现iOS5上有一些问题。此应用程序通过avaudioplayer播放mp3文件,遥控器在iOS 5上无法正常工作 此应用程序中有四个视图控制器。为了实现远程控制功能,我在每个视图控制器上添加了以下代码。问题是,当视图控制器第一次打开时。遥控按钮工作正常,即使应用程序在后台运行或锁定屏幕。但是,当我单击另一个视图控制器并返回上一个打开时,遥控器不再工作。但是每次都会调用canBecomeFirstResponder函数 我甚至试着把 [[UI

我有一个应用程序在iOS 4.3.3上运行良好。但是我发现iOS5上有一些问题。此应用程序通过avaudioplayer播放mp3文件,遥控器在iOS 5上无法正常工作

此应用程序中有四个视图控制器。为了实现远程控制功能,我在每个视图控制器上添加了以下代码。问题是,当视图控制器第一次打开时。遥控按钮工作正常,即使应用程序在后台运行或锁定屏幕。但是,当我单击另一个视图控制器并返回上一个打开时,遥控器不再工作。但是每次都会调用canBecomeFirstResponder函数

我甚至试着把 [[UIApplication sharedApplication]开始接收RemoteControlEvents]; 在委托函数中 (BOOL)应用程序:(UIApplication*)应用程序使用选项完成启动:(NSDictionary*)启动选项 它不起作用

我不明白为什么会这样。它折磨了我好几天。 在多视图控制器中是否有更好的方式实现远程控制功能

顺便说一句,我在info.plist中添加了UIBackgroundModes音频键。这个应用程序在后台运行良好

任何帮助都将不胜感激

- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];

[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
}
- (void)viewWillAppear:(BOOL)animated {
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
}  
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
[self resignFirstResponder];
}
- (BOOL) canBecomeFirstResponder {
NSLog(@"Can be first responder!");
return YES;
}
- (void)remoteControlReceivedWithEvent:(UIEvent *)event
{
if (event.subtype == UIEventSubtypeRemoteControlTogglePlayPause) {
    NSLog(@"UIEventSubtypeRemoteControlTogglePlayPause");
    [self playAndpause:nil];
}
}