取消錯誤在我的iOS SpriteKit的應用程序,我玩用AVAudioPlayer配音一定數額的秒後用戶操作後,像這樣:IOS:雖然performrequest
[self.vOSoundManager performSelector:@selector(playVoiceOverWithName:) withObject:@"Voiceover_waarhondenbrokken3" afterDelay:8.0];
[self.vOSoundManager setRequestBeingPerformed:TRUE];
當用戶執行其他操作,聲音應該停止播放。我這樣做,像這樣:
if(self.vOSoundManager.requestBeingPerformed){
[NSObject cancelPreviousPerformRequestsWithTarget:self.vOSoundManager];
[self.vOSoundManager stopCurrentSound];
}
的stopCurrentSound方法VoiceOverSoundManager:
- (void)stopCurrentSound{
self.playing = FALSE;
[self.voiceOverPlayer stop];
self.voiceOverPlayer = nil;
}
當cancelPreviousPerformRequestsWithTarget方法被調用時,我收到以下錯誤:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[VoiceOverSoundManager name]: unrecognized selector sent to instance 0x155a9590'
我不知道爲什麼。有沒有人有辦法解決嗎?
在你的代碼或self.voiceOverPlayer中是否還有其他AVAudioPlayer實例嗎?你是否使用唯一一個播放所有聲音的播放器? – Whirlwind 2015-01-21 13:06:33
我使用VoiceOverSoundManager的其他實例(使用AVAudioPlayer),但我實現了它們來嘗試解決此問題。所以在實施之前,問題也在那裏。 – Cas 2015-01-21 13:10:36