目标C:等到AVSpeechSynthesizer完成一个单词的发音

我需要禁用与用户的交互,直到应用程序完成讲话。 看下面的例子代码:

self.view.userInteractionEnabled = NO; [self speak :@"wait for me to speak"]; self.view.userInteractionEnabled = YES; -(void)speak:(NSString*)word { AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc] initWithString:word]; utterance.rate = AVSpeechUtteranceMinimumSpeechRate; utterance.rate = 0.2f; utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage [AVSpeechSynthesisVoice currentLanguageCode]]; [synthesizer speakUtterance:utterance]; } 

使用委托( AVSpeechSynthesizerDelegate )。 它会告诉你何时讲话结束,现在再次启用用户交互。