在应用程序说完之前,我需要禁用与用户的交互。请参见下面的示例代码:
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];
}