I am making a custom keyboard. The delete key in the keyboard works fine for single tap. But it does not work for long press.I want to implement the long press on the delete key so that when the user holds down the delete button, the keyboard continuously deletes like in the standard ios keyboard. I referred to a couple of solutions on Stackoverflow, like- https://stackoverflow.com/a/26234876/6077720, https://stackoverflow.com/a/25633313/6077720, https://stackoverflow.com/a/30711421/6077720
But none of it worked for me. I also tried this code:
override func viewDidLoad() {
super.viewDidLoad()
textDocument = self.textDocumentProxy
var longPress = UILongPressGestureRecognizer(target: self, action: #selector(self.longPress))
self.deleteKeyPressed.addGestureRecognizer(longPress)
}
func longPress(gesture: UILongPressGestureRecognizer) {
if gesture.state == .Ended {
print("Long Press")
self.textDocumentProxy.deleteBackward()
}
}
But after writing this code my keyboard does not appear only. Can anyone please help me?