当自定义键盘修改更新的文本时,UIInputViewController
中是否有方法? textWillChange
/ textDidChange
仅通知我有关光标移动的信息。
答案 0 :(得分:0)
子类UIInputView
。在您的子类中,设置protocol
。
protocol MyCustomInputViewDidChangeDelegate {
func customInputViewDidChange(customInputView: MyCustomInputView)
}
class MyCustomInputView: UIInputView {
var delegate: MyCustomInputViewDidChangeDelegate?
}
您UIInputViewController
符合MyCustomInputViewDidChangeDelegate
触摸自定义键盘时,请在适当时通过调用delegate?.customInputViewDidChange(self)
将其传播给代理人。
答案 1 :(得分:0)
有UITextFieldTextDidBeginEditingNotification,UITextFieldTextDidEndEditingNotification,UITextFieldTextDidChangeNotification 你可以使用
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(self.textFieldDidChanged(_:)), name: UITextFieldTextDidEndEditingNotification, object:self.txtAlbumName)
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(self.textFieldDidChanged(_:)), name: UITextFieldTextDidChangeNotification, object:self.txtAlbumName)
// ------------
func textFieldDidChanged(sender:NSNotification) -> Void {
}
func textFieldDidChanged (sender:NSNotification) -> Void{
}
}