想要在单击特定注释引脚时执行textToSpeak方法。什么是正确的方法?

时间:2014-05-15 01:19:25

标签: ios mkmapview mkannotation

#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>

@interface Annotation : NSObject<MKAnnotation>
@property(nonatomic, assign) CLLocationCoordinate2D coordinate;
@property (nonatomic, copy) NSString * title;
@property ( nonatomic, copy)NSString * subtitle;
- (void)textToSpeak:(NSString *  )theString;

@end

#import "Annotation.h" #import <AVFoundation/AVFoundation.h>

@implementation Annotation

@synthesize coordinate, title, subtitle;

-(void)textToSpeak:(NSString *)theString{


AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:theString   ];
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US" ];
utterance.rate = 0.70*AVSpeechUtteranceDefaultSpeechRate;

AVSpeechSynthesizer *synth= [[AVSpeechSynthesizer alloc]init];
[synth speakUtterance:utterance ];



}@end

//我有一个简单的注释类。在我的ViewController.m中,我可以根据需要显示所有引脚。问题是我想在每次单击特定引脚时执行操作。说出标题名称的动作。任何指导都会有用。谢谢!

0 个答案:

没有答案