我试图让AVSpeech在字符串*组合中说出两个NSString并将其传递给AVSpeech。但只有* speekone被传递给* combine字符串。所以我只说了第一个字符串。我是以某种方式声明字符串错误还是需要更改我的方法?
- (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];
答案 0 :(得分:0)
stringWithFormat
的第一个参数不是格式说明符。
这一行:
NSString *combined = [NSString stringWithFormat:speekone, speektwo];
应该成为:
NSString *combined = [NSString stringWithFormat:@"%@ %@", speekone, speektwo];