iOS:如何检测语音指令是否用于UITextField?或在键盘上点击了麦克风按钮 [英] ios: how to detect if voice dictation was used for UITextField? Or microphone button was tapped on keyboard

查看:277
本文介绍了iOS:如何检测语音指令是否用于UITextField?或在键盘上点击了麦克风按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检测语音指令是否用于UITextField?或在键盘上点击了麦克风按钮. 有什么办法吗?

How to detect if voice dictation was used for UITextField? Or microphone button was tapped on keyboard. Is there any way to do that?

推荐答案

UITextField符合 在此协议中,您可以覆盖方法 dictationRecordingDidEnd .

UITextField conforms to UITextInput Protocol ( under the section Using Dictation are methods of interest). In this protocol is a method dictationRecordingDidEnd that you can override.

一种方法是继承 UITextField 并实现上述方法以及 UITextInput 协议中感兴趣的其他方法.

One way is to subclass UITextField and implement the above mentioned method and any others of interest from the UITextInput protocol.

示例子类 .h

#import <UIKit/UIKit.h>

@interface BWDictationTextField : UITextField

@end

.m

#import "BWDictationTextField.h"

@implementation BWDictationTextField
     - (void)dictationRecordingDidEnd {
          NSLog(@"%s", __PRETTY_FUNCTION__);
     }// done is pressed by user after dictation
@end

不幸的是,没有记录下来的方法来检测麦克风按钮的实际轻拍(听写开始了).

Unfortunately there is no documented way to detect the actual tap of the microphone button ( dictation did start ).

这篇关于iOS:如何检测语音指令是否用于UITextField?或在键盘上点击了麦克风按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆