watch os 語音輸入,watchos
WatchKit提供了一個標準的模態介面,用於從使用者檢索文字輸入。當呈現,介面允許使用者通過聽寫輸入文字或從標準組短語或Emoji,
import WatchKitimport Foundationclass ComplaintInterfaceController: WKInterfaceController { @IBOutlet var inputText: WKInterfaceLabel! override func awakeWithContext(context: AnyObject?) { super.awakeWithContext(context) // Configure interface objects here. } override func willActivate() { // This method is called when watch view controller is about to be visible to user super.willActivate() } override func didDeactivate() { // This method is called when watch view controller is no longer visible super.didDeactivate() } //語音輸入 @IBAction func inputAction() { let initialPhrases = ["垃圾應用.", "還有沒有更垃圾的應用?", "這是免費得嗎?"]; self.presentTextInputControllerWithSuggestions(initialPhrases, allowedInputMode: WKTextInputMode.Plain) { (results) -> Void in if results != nil && results!.count > 0 { let aResult = results![0] print(aResult) self.inputText.setText(aResult as? String) } else { print("錯誤") } } } @IBAction func suggestPlaint() { print("已經提交") } }