禁用iPhone 4S /新iPad的键盘上的听写button

我们是一个健康护理应用程序。 我们在应用程序中使用了符合HIPAA标准的语音识别器,通过它可以进行所有的听写。 医院不希望医生意外地开始与不符合HIPAA标准的Nuance Dragon服务器交谈。 所以,我正在寻找可以抑制键盘上的听写键的方法。

我尝试在键盘上的听写button上放置一个假button,但在iPad上,分离式button的概念不断将麦克风移动到屏幕上。 这听起来不是一个合理的解决scheme。 有没有专家可以帮助我?

OKAY,终于明白了! 诀窍是观察UITextInputMode更改通知,然后收集更改的模式的标识符(代码似乎避免直接使用私有API,虽然似乎需要一些私有API的一般知识),当模式改变听写,辞职的第一个答案(这将取消语音听写)。 好极了! 这里是一些代码:

在你的应用程序委托的某个地方(至less这是我把它放在哪里)

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(inputModeDidChange:) name:@"UITextInputCurrentInputModeDidChangeNotification" object:nil]; 

然后你可以

 UIView *resignFirstResponder(UIView *theView) { if([theView isFirstResponder]) { [theView resignFirstResponder]; return theView; } for(UIView *subview in theView.subviews) { UIView *result = resignFirstResponder(subview); if(result) return result; } return nil; } - (void)inputModeDidChange:(NSNotification *)notification { // Allows us to block dictation UITextInputMode *inputMode = [UITextInputMode currentInputMode]; NSString *modeIdentifier = [inputMode respondsToSelector:@selector(identifier)] ? (NSString *)[inputMode performSelector:@selector(identifier)] : nil; if([modeIdentifier isEqualToString:@"dictation"]) { [UIView setAnimationsEnabled:NO]; UIView *resigned = resignFirstResponder(window); [resigned becomeFirstResponder]; [UIView setAnimationsEnabled:YES]; UIAlertView *denyAlert = [[[UIAlertView alloc] initWithTitle:@"Denied" message:nil delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil] autorelease]; [denyAlert show]; } } 

您可以创build自己的键盘,并设置将接受此听写的文本字段的inputView。 然后当他们按任何键他们会得到你的键盘,因此你不必重写标准键盘上的键,你将能够自定义整个事情。

 self.myButton.inputView = self.customKeyboardView; 

这里是一个非常自定义键盘的例子

http://blog.carbonfive.com/2012/03/12/customizing-the-ios-keyboard/

Ray还为自定义键盘提供了一个独特的教程。

http://www.raywenderlich.com/1063/ipad-for-iphone-developers-101-custom-input-view-tutorial

我希望有帮助。

我有同样的问题,唯一的办法,我发现隐藏听写button正在改变键盘types。 对我来说,将其改为电子邮件types似乎是合理的:

 textField.keyboardType = UIKeyboardTypeEmailAddress; 

你可以创build一个覆盖insertDictationResult的UITextField / UITextView的子类:不要插入任何东西。

这不会阻止信息的发送,但是你可以显示一个警告通知他们的臀位。