如何检测 UITextField 是否使用了语音听写?或者点击键盘上的麦克风按钮。
有什么办法可以做到这一点吗?
UITextField 符合UI文本输入协议 https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UITextInput_Protocol/index.html#//apple_ref/occ/intfm/UITextInput/dictationRecordingDidEnd (在“使用听写”部分下是感兴趣的方法)。在这个协议中有一个方法听写录音结束您可以覆盖。
一种方法是子类化UI文本字段并实施上述方法和任何其他感兴趣的方法UI文本输入协议。
示例子类.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
不幸的是,没有记录的方法来检测麦克风按钮的实际点击(听写确实开始了)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)