有没有人能帮我提供一段示例代码,用于在Apple Watchkit应用程序中添加语音转文本功能。
[self presentTextInputControllerWithSuggestions:@[@"hello", @"world"] allowedInputMode:WKTextInputModePlain completion:^(NSArray *results) {
NSLog(@"results: %@", results);
}];
这就是结果:
self.presentTextInputControllerWithSuggestions(["suggestion 1", "suggestion 2"] allowedInputMode: .Plain, completion: { (answers) -> Void in
if reply && reply.count > 0 {
if let answer = answers[0] as? String {
println("\answer")
}
}
})
self.presentTextInputControllerWithSuggestions(["Y","N"], allowedInputMode: WKTextInputMode.Plain,
completion:{(results) -> Void in
let aResult = results?[0] as? String
print(aResult)
})