11

Is there a way to modify or make your own iPhone keyboard so that you can type in unsupported languages?

hekevintran
  • 22,822
  • 32
  • 111
  • 180
  • 2
    Actually, this is possible. The Answer you accepted is ***NOT*** correct. Take a look at @Anomies answer, that is how you can implement a custom keyboard. – RyanR Jun 26 '11 at 00:13
  • @RyanR: The accepted answer was correct back in 2009; iOS 3.0 had just been released when the question was asked and answered. My answer requires iOS 3.2. I'm not sure why alok posted a bounty on such an old question. – Anomie Jun 26 '11 at 15:13

2 Answers2

13

You can create your own keyboard, but actually using it is more difficult.

To create it:

  1. Create the keyboard view. You can use whichever subviews you want. The most useful way to do this is probably to create a UIView subclass.
  2. Arrange for an instance of your keyboard view to be returned by any UIResponder's inputView property. For UITextView and UITextField, this is as simple as assigning the property; for other classes, you will probably have to subclass or swizzle the accessors as the property is declared read-only by default.

More details on this are available in the documentation.

Unfortunately, actually using this custom keyboard is more difficult. As of iOS 4.3, neither UITextField nor UITextView conform to the UITextInput protocol, which would be ideal for this purpose. For UITextView you should be able to make it work using the methods provided by the class, but since UITextField doesn't give any way to find the current selection or cursor position you won't be able to create a fully-functional keyboard using publicly-documented methods (append and delete-from-end are possible, and even inserting at the current position by manipulating the clipboard, but a "delete previous character" button like that on the standard keyboard will prove impossible).

As of iOS 5.0, UITextField and UITextView finally do implement the UITextInput protocol. It should now be a simple matter to insert and delete text at the cursor position.

Community
  • 1
  • 1
Anomie
  • 92,546
  • 13
  • 126
  • 145
6

No, there is currently no way to do this.

There are some hacky ways of adding your own button via adding SubViews. But it is unsupported and could fail at any time.

If you decided to create your own, you would probably have to roll your own textbox control and any other control that needs a keyboard. In other words, not really an ideal option.

Jab
  • 13,713
  • 2
  • 42
  • 48