0

Is there a method in UIInputViewController when the text that the custom keyboard is modifying updates? textWillChange/textDidChange only notify me about cursor movement.

Stanislav Pankevich
  • 11,044
  • 8
  • 69
  • 129
Foobar
  • 7,458
  • 16
  • 81
  • 161

2 Answers2

0

Subclass UIInputView. In your subclass, set up a protocol.

protocol MyCustomInputViewDidChangeDelegate {
    func customInputViewDidChange(customInputView: MyCustomInputView)
}

class MyCustomInputView: UIInputView {
    var delegate: MyCustomInputViewDidChangeDelegate?
}

You'll have UIInputViewController conform to MyCustomInputViewDidChangeDelegate When your custom keyboard is touched, propagate that to the delegate when appropriate by calling delegate?.customInputViewDidChange(self).

BenJammin
  • 1,479
  • 13
  • 18
0

there are UITextFieldTextDidBeginEditingNotification, UITextFieldTextDidEndEditingNotification, UITextFieldTextDidChangeNotification You can use

   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{

  }
}
AppHero2
  • 681
  • 7
  • 25