我想知道听写什么时候结束(最好是什么时候开始)。
我的UIViewController
其中包括UITextView
符合UITextInputDelegate
协议的。
为了使它工作,我必须订阅UITextInputCurrentInputModeDidChangeNotification
override func viewDidLoad() {
super.viewDidLoad()
NSNotificationCenter.defaultCenter().addObserver(self, selector: "changeInputMode:", name: UITextInputCurrentInputModeDidChangeNotification, object: nil)
}
并在那里添加委托(仅将其添加到viewDidLoad()中不起作用)
func changeInputMode(sender : NSNotification) {
textView.inputDelegate = self
}
开始和停止听写 UITextInput 现在可以正确调用所需的委托方法:
func selectionWillChange(textInput: UITextInput){ }
func selectionDidChange(textInput: UITextInput){ }
func textWillChange(textInput: UITextInput){ }
func textDidChange(textInput: UITextInput){ }
但是没有被调用的是
func dictationRecordingDidEnd() {
println("UITextInput Dictation ended")
}
为什么?如何在听写结束时收到通知/调用方法?