你好我理解TTS仅在iOS 7中可用,但我过去使用了很多apis,检查该类是否可用并设法保留以前版本的兼容性,但是使用AVSpeechSynthesizer它似乎不起作用,请你帮我使用适用于iOS 7的TTS并通过在iOS 6中禁用它来保持兼容性,非常感谢.
这是我的代码,但它似乎不起作用
if (([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)) { if([AVSpeechSynthesizer class]) { AVSpeechSynthesizer *synth = [[AVSpeechSynthesizer alloc] init]; AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:text]; utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"]; utterance.rate = AVSpeechUtteranceDefaultSpeechRate/2; utterance.pitchMultiplier = 0.9; utterance.preUtteranceDelay = 0; utterance.postUtteranceDelay = 0; [synth speakUtterance:utterance]; } else { // Feature not available, do something else } }
我已经在我的项目中链接了avfoundation并设置了部署目标iOS 6,它似乎仅在iOS 7设备上运行时工作,如果它的iOS 6崩溃了.
这是我得到的错误消息
dyld: Symbol not found: _AVSpeechUtteranceDefaultSpeechRate
Josh Brown.. 6
框架需要弱联系.请执行下列操作:
单击Project Navigator(左侧)中的项目文件,在编辑器中打开项目
单击编辑器中的Build Phases选项卡
展开Link Binary With Libraries部分
将AVFoundation.framework从Required设置为Optional
此外,您可能希望使用更安全(并由Apple推荐)更新版本检查.
框架需要弱联系.请执行下列操作:
单击Project Navigator(左侧)中的项目文件,在编辑器中打开项目
单击编辑器中的Build Phases选项卡
展开Link Binary With Libraries部分
将AVFoundation.framework从Required设置为Optional
此外,您可能希望使用更安全(并由Apple推荐)更新版本检查.