我正在使用背景音頻播放應用程序。我已經按照應用程序文檔的指示編寫了iPod控件的代碼。我已經實現這個喜歡AVAudio中的remoteControlReceivedWithEvent未被調用
- (void) remoteControlReceivedWithEvent: (UIEvent *) receivedEvent {
if (receivedEvent.type == UIEventTypeRemoteControl) {
switch (receivedEvent.subtype) {
case UIEventSubtypeRemoteControlTogglePlayPause:
[self playButtonPressed:playButton];
[self testing];
break;
case UIEventSubtypeRemoteControlPreviousTrack:
[self rewButtonReleased:(UIButton *)rewButton];
break;
case UIEventSubtypeRemoteControlNextTrack:
[self ffwButtonReleased:(UIButton *)ffwButton];
break;
default:
break;
}
}
}
- (BOOL)canBecomeFirstResponder {
NSLog(@"canBecomeFirstResponder");
return YES;
}
和
- (void) viewDidAppear:(BOOL)animated
{
if ([[UIApplication sharedApplication] respondsToSelector:@selector(beginReceivingRemoteControlEvents)]){
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
}
}
- (void) viewWillDisappear:(BOOL)animated
{
[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
[self resignFirstResponder];
}
請建議我還有什麼,我需要和我在哪裏犯任何錯誤。問候!
爲什麼?有什麼意義? – openfrog