Reputation: 5343
Is there a way to perform dictation on click of a button outside the iOS keyboard.
For ex: I have a UITextField
with microphone button right. On the click of this button, it should open the same dialog/view as when microphone button is clicked inside the keyboard.
Upvotes: 8
Views: 2478
Reputation: 2251
I have been doing a research on this for a while now and could not find a solution for this yet.
You cannot trigger the microphone button outside the keyboard as in the native iPhone search bar in the home screen. This is a private API which is not available for development.
The best possible alternative is to use the Speech framework provided by Apple available in iOS 10.0+ and build your own custom UI to convert speech to text.
Hope this information helps! :)
Upvotes: 11
Reputation: 186
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.
One way is to subclass UITextField and implement the above mentioned method and any others of interest from the UITextInput protocol.
example subclass .h
#import <UIKit/UIKit.h>
@interface TextField : UITextField
@end
.m
#import "TextField.h"
@implementation TextField
-(void)dictationRecordingDidEnd {
NSLog(@"%s", __PRETTY_FUNCTION__);
}// done is pressed by user after dictation
@end
Upvotes: -4