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 (将#修改为@)