0

I created a custom keyboard using buttons, but now I'm stuck with buttons that don't do anything.

How will I connect them to a text field?

enter image description here

Irfan
  • 4,301
  • 6
  • 29
  • 46
blanc
  • 25
  • 5

2 Answers2

0

First, you should be aware of the inputView property of the UITextField/UITextView classes. Basically you can have a custom view (your keyboard for example) and swap it with the default keyboard.

You can get some inspiration from this tutorial that shows how to create a custom keyboard - and how to connect it to your textfield/textview.

You can also read this answer for another way to connect your keyboard to a textfield/textview.

Community
  • 1
  • 1
Ilea Cristian
  • 5,741
  • 1
  • 23
  • 37
0

You can handle buttons touchUpInside Action like this to insert text in uitextfield

@IBAction func btnQuestionAction(_ sender: UIButton)
{
    self.textDocumentProxy.insertText("?")

}

And to delete character using custom keyboard, You can use this:

@IBAction func btnBackspaceAction(_ sender: UIButton)
{
    self.textDocumentProxy.deleteBackward()
}

Hope it will help you :)

Anjali jariwala
  • 410
  • 5
  • 15