2
我試圖使用我的代碼來兼容iOS 6 & 7,使用合成語音。 我想它可用於iOS 7,不適用於iOS 6.dyld:找不到符號:_AVSpeechUtteranceMaximumSpeechRate
問題是,當我在iOS 6的模擬器中運行時,即使在模擬器啓動之前,它也給出以下錯誤:dyld: Symbol not found: _AVSpeechUtteranceMaximumSpeechRate
。
如果我對此行發表評論:utterance.rate = AVSpeechUtteranceMaximumSpeechRate/4.0f;
對於iOS 6的啓動非常適用,即使它不是爲它設計的。
問題是什麼?
謝謝。
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
// Load resources for iOS 7 or later
AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc] init];
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:selectedText];
utterance.rate = AVSpeechUtteranceMaximumSpeechRate/4.0f;
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"]; // defaults to your system language
[synthesizer speakUtterance:utterance];
[synthesizer release];
}
else{
// Load resources for iOS 6 or earlier
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Sorry"
message:@"This feature requires iOS 7.0 or later"
delegate:Nil
cancelButtonTitle:@"OK"
otherButtonTitles: nil] autorelease];
[alert show];
}
謝謝,這真的解決了這個問題 –