我正在尝试让AVSpeech说出字符串*中的两个NSString并将其传递给AVSpeech。但它是唯一传递给*组合字符串的*speekone。所以我只说了第一个字符串。不知何故,我声明的字符串是错误的,还是我需要更改我的方法?
- (IBAction)UIButtonPlayPressed:(UIButton *)sender{
NSString *speekone = _activity.activityName;
NSString *speektwo = _activity.activityDescription;
NSString *combined = [NSString stringWithFormat:speekone, speektwo];
if (speechPaused == NO) {
//Title for button [self.UIButtonPlay setTitle:@"Pause" forState:UIControlStateNormal];
[self.synthesizer continueSpeaking];
speechPaused = YES;
NSLog(@"playing");
} else {
//Titleforbutton [self.UIButtonPlay setTitle:@"Play" forState:UIControlStateNormal];
speechPaused = NO;
[self.synthesizer pauseSpeakingAtBoundary:AVSpeechBoundaryImmediate];
NSLog(@"paused");
}
if (self.synthesizer.speaking == NO) {
AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc] initWithString:combined];
[self.synthesizer speakUtterance:utterance];发布于 2016-02-28 23:00:30
stringWithFormat的第一个参数不是格式说明符。
这一行:
NSString *combined = [NSString stringWithFormat:speekone, speektwo];应该变成:
NSString *combined = [NSString stringWithFormat:@"%@ %@", speekone, speektwo];https://stackoverflow.com/questions/35683978
复制相似问题