Tom Coomer
Tom Coomer

Reputation: 6527

Text Input Controller WatchKit

I am trying to use presentTextInputControllerWithSuggestions in a WatchKit app. I am not sure where I am going wrong.

presentTextInputControllerWithSuggestions(["Hello", "Hey"], completion: { 
    (myString) -> Void in
    println(myString)
    })

Upvotes: 3

Views: 3387

Answers (3)

jfgrang
jfgrang

Reputation: 1178

You can try by tapping on a suggestion. It should do exactly the same as dictating. Beware, the completion returns an array and not a string. You should do it like that

self.presentTextInputControllerWithSuggestions(["Suggestion 1", "Suggestion 2"] allowedInputMode: .Plain, completion: { (selectedAnswers) -> Void in
    if reply && reply.count > 0 {
        if let spokenReply = selectedAnswers[0] as? String {
            println("\(spokenReply)")
        }
    }
})

Upvotes: 5

brian.clear
brian.clear

Reputation: 5327

From Apple Dev Forums

Its the same a pressing microphone on the iPhone keyboard and dictating.

The Audio goes off to apple and returns and hopefully the text you spoke is returned as a String.

Upvotes: 0

zisoft
zisoft

Reputation: 23078

From the iOS 8.2 Release Notes:

WatchKit

Known Issues

The presentTextInputControllerWithSuggestions:completion: method of WKInterfaceController is not currently supported in iOS Simulator.

Upvotes: 7

Related Questions