In my Apple Watch app I need to input text, so is there any way to input text in my app with voiceOver or any other ways?
As I have seen none of the objects in WKInterfaceController support editable text inputs like UITextfield or UITextview.
The above answer has no code, just a link to Apple's awesome XD documentation. You can launch a speech recognition menu with some voice options using this code (WatchOS2, iOS 9.2.1):
//LAUNCH VOICE DICTATION (physical device only)
func launchVoiceDictationMenu(){
self.presentTextInputControllerWithSuggestions(["Hello","Goodbye","Hey"], allowedInputMode: WKTextInputMode.Plain,
completion:{(results) -> Void in
let aResult = results?[0] as? String
print(aResult)
})
}
With watchOS 3 welcome the new "scribble" mode
[self presentTextInputControllerWithSuggestions:@[@"watchOS3"]; allowedInputMode:WKTextInputModePlain completion:^(NSArray *array){
if (array != nil) {
for (int i=0; i<[array count]; i++) {
NSString *str = [array objectAtIndex:0];
NSLog(@"%@",str);
}
}
}];
Yes, you can input text in Apple Watch using dictation (the watch has a microphone) or by selecting an emoji right on the screen. From Apple Documentation:
WatchKit provides a standard modal interface for retrieving text input from the user. When presented, the interface allows the user to enter text via dictation or to select from a standard set of phrases or emoji.
Swift 4
@IBAction func ReplyWithTextInputController(){
let phrases = ["OK", "I'm busy.", "Where are you?", "Thanks."]
presentTextInputController(withSuggestions: phrases,
allowedInputMode: WKTextInputMode.allowEmoji, completion: { (result) -> Void in
guard let choice = result else {
return
}
let suggestion = choice[0]
print(suggestion)
})
}