【发布时间】:2015-02-27 10:17:20
【问题描述】:
我想知道听写什么时候结束(最好是什么时候开始)。
我的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")
}
为什么?如何在听写结束时收到通知/调用方法?
【问题讨论】:
标签: ios swift uitextview dictation