我们的应用程序是一个医疗保健应用程序。我们的应用程序中有一个符合 HIPAA 标准的语音识别器,所有听写都可以通过它进行。医院不希望医生意外开始与不符合 HIPAA 标准的 Nuance Dragon 服务器进行对话。因此,我正在寻找可以抑制键盘上听写键的方法。
我尝试在键盘上的“听写”按钮上放置一个假按钮,但在 iPad 上,分体式底座概念使麦克风不断在屏幕上移动。这听起来不像是一个合理的解决方案。有专家可以帮助我吗?
好的,终于明白了!诀窍是观察 UITextInputMode 更改通知,然后收集更改模式的标识符(代码似乎避免直接使用 Private API,尽管通常似乎需要对私有 API 有一点了解),以及模式何时更改要听写,请 resignFirstResponder (这将取消语音听写)。耶!这是一些代码:
在您的应用程序委托中的某个位置(至少我把它放在那里)
[[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];
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)