微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Siri 听写重复我在 UITextView 上说的话

如何解决Siri 听写重复我在 UITextView 上说的话

当我听写一个文本或单词时,当我想在 UITextView 中书写时,Siri 接收器会以某种方式重复每个捕获的单词,我的 UITextView 实现得尽可能简单:

#pragma mark - UITextViewDelegate
- (BOOL) textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(Nsstring *)text
{
     return YES;
}
- (void)textViewDidChange:(UITextView *)textView
{
//  NSLog(@"-> textViewDidChange: %@",textView.text);
  if (textView == self.txtViewItem)
  {
    if ([self sameCharsInString:textView.text])
    {
      Nsstring *firstChar = [textView.text substringWithRange:NSMakeRange(0,1)];
      textView.text = firstChar;
    }
    if (textView.text.length > 1)
    {
      Nsstring * character = [textView.text substringWithRange:NSMakeRange(1,1)];
      textView.text = [textView.text stringByReplacingCharactersInRange:NSMakeRange(1,1) withString:[character lowercaseString]];
    }
  }
}
-(BOOL)sameCharsInString:(Nsstring *)str{
  if ([str length] == 0 ) return NO;
  return [[str stringByReplacingOccurrencesOfString:[str substringToIndex:1] withString:@""] length] == 0 ? YES : NO;
}

那么如何检测 Siri Dictation 是否用于 UITextView,请帮忙?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。