【问题标题】:Issue AVSpeechUtterance发出 AVSpeechUtterance
【发布时间】:2016-02-28 23:00:30
【问题描述】:

我试图让 AVSpeech 说出字符串 *combine 中的两个 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];

【问题讨论】:

    标签: objective-c iphone avspeechsynthesizer


    【解决方案1】:

    stringWithFormat 的第一个参数不是格式说明符。

    这一行:

    NSString *combined = [NSString stringWithFormat:speekone, speektwo];
    

    应该变成:

    NSString *combined = [NSString stringWithFormat:@"%@ %@", speekone, speektwo];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多