3

我编写了代码以在我的 Apple Watch 上使用听写。我使用没有建议的 presentTextInputControllerWithSuggestions 直接开始听写。

但是,我有两个问题:

  • 我想在我的应用程序启动时开始听写。为此,我在 willActivate 方法中调用我的函数,但是这样,我的屏幕上只出现了一个等待图像,而不是我的第一页听写。
  • 我想在不按“完成”按钮的情况下停止听写。我不知道这是否可能,我怎样才能做到这一点。

有我的代码:

func dictation(){
        self.presentTextInputControllerWithSuggestions([], allowedInputMode: WKTextInputMode.Plain, completion:{
            (results) -> Void in
                 //myCode
            })
    }
override func willActivate(){
   super.willActivate()
   dictation()
}

你有解决方案吗?

4

1 回答 1

0

感谢您的帮助@Feldur

我尝试了延迟,它似乎有效

有我的代码:

override init(){
    super.init()
    print("start init")
    let seconds = 1.0
    let delay = seconds * Double(NSEC_PER_SEC)  // nanoseconds per seconds
    let dispatchTime = dispatch_time(DISPATCH_TIME_NOW, Int64(delay))
    dispatch_after(dispatchTime, dispatch_get_main_queue(), {
        self.dictation()
    })
    print("end init")
}

有我的日志:

start init
end init
start awakeWithContext
end awakeWithContext
start willactivate
end willactivate
start didAppear
end didAppear
start dictation

我的屏幕出现后,我的听写开始。

当用户停止讲话时,您有停止听写的想法吗?

于 2016-07-14T07:08:27.063 回答