文本输入控制器WatchKit

Tom*_*mer 3 swift watchkit

我想presentTextInputControllerWithSuggestions在一个WatchKit应用程序中使用.我不确定我哪里出错了.

presentTextInputControllerWithSuggestions(["Hello", "Hey"], completion: { 
    (myString) -> Void in
    println(myString)
    })
Run Code Online (Sandbox Code Playgroud)

zis*_*oft 7

iOS 8.2发行说明:

WatchKit

已知的问题

iOS模拟器中目前不支持presentTextInputControllerWithSuggestions:completion:WKInterfaceController方法.


jfg*_*ang 5

您可以尝试点击建议.它应该与口述完全相同.请注意,完成返回一个数组而不是字符串.你应该这样做

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)")
        }
    }
})
Run Code Online (Sandbox Code Playgroud)