这个问题在这里已经有了答案:
WatchKit Option to ONLY Dictate?
(2 个回答)
6年前关闭。
根据 Apple 的文档 WKInterfaceController您可以让用户以这种非常简单的方式来指示预设新界面 Controller 的文本:
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")
}
}
})
如解释 here .
我已经看到 Apple Watch 的 Amazon App 让您可以通过直接点击搜索图标来搜索产品
因此,您可以一步进入听写
通过
WKInterfaceController
方法,我们会得到不同的东西哪个 Apple 的 API Amazon 应用程序正在使用这种方式启用听写?
(更新)
我刚刚发现它非常简单,正如 here 所解释的那样
所以我出来的最终解决方案是这个
- (void) table:(WKInterfaceTable *)table didSelectRowAtIndex:(NSInteger)rowIndex {
if (rowIndex==0) { // handle manual selection
__weak MainInterfaceController *weakSelf = self;
[self presentTextInputControllerWithSuggestions:nil allowedInputMode:WKTextInputModePlain completion:^(NSArray *results) {
if(results && [results count]>0) {
NSString *inputText=nil;
for(NSString *input in results) {
NSLog(@"Input %@", input);
inputText=input;
break;
}
if(inputText!=nil && [inputText length]>0) {
[weakSelf pushControllerWithName:@"Search" context:
[NSDictionary dictionaryWithObjectsAndKeys:
inputText, @"query", nil]
];
}
} else {
NSLog(@"No input provided");
}
}];
}}
最佳答案
设置模式为.Plain
并且不提供任何建议。
关于ios - Watchkit:通过 WKInterfaceController 单击文本听写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30460008/