在iOS上将audio添加到地图

我现在有一张地图,上面有几个相近的地图。 现在,当用户点击注释时,会popup一个小小的名字。 我怎么能这样做,以便有关该位置的audio播放?

我不是暂停button等fussed,现在我想知道我如何实现audio到这个!

使用AVSpeechSynthesizer

AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc]init]; AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:@"Some random text that you want to be spoken"]; [utterance setRate:0.7]; [synthesizer speakUtterance:utterance]; 

http://jonathanfield.me/avspeechsynthesizer-ios-text-speech-ios-7/

文本到语音转换

更新:

将委托添加到您的MKMapView。 例如,它可能是self

 self.mapView.delegate = self; 

(自己应该确认到MKMapViewDelegate)。 并实现委托的方法

 - (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)anView { AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc]init]; AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:anView.annotation.title]; [utterance setRate:0.7]; [synthesizer speakUtterance:utterance]; } 
Interesting Posts