Class

UIInputViewController

The primary view controller for a custom keyboard app extension.

Declaration

@interface UIInputViewController : UIViewController

Overview

To create a custom keyboard, first subclass the UIInputViewController class, then add your keyboard’s user interface to the inputView property of your subclass. In Xcode, you can start a custom keyboard by choosing the Custom Keyboard target template.

A custom keyboard can respond to user input events in the following ways:

  • Add text in the form of an unattributed NSString object at the insertion point in the current text input object, by calling the insertText: method on the textDocumentProxy property. This property provides that method through its conformance to the UIKeyInput protocol

  • Delete text in a backward direction, starting at the insertion point, by calling the deleteBackward method on the textDocumentProxy property.

  • Switch to another keyboard in the set of user-enabled keyboards, by calling the advanceToNextInputMode method.

  • Dismiss the keyboard, by calling the dismissKeyboard method.

Obtain textual context around the insertion point by reading the textDocumentProxy properties documentContextBeforeInput and documentContextAfterInput. To find out if the current text input object is empty, call the hasText method on the textDocumentProxy property. You can employ this textual context by considering it along with user input, to offer context-sensitive output to a document from your keyboard.

An input view controller conforms to the UITextInputDelegate protocol, allowing you to respond to changes in document content and position of the insertion point.

To present an appropriate keyboard layout, respond to the current text input object’s UIKeyboardType property. For each keyboard type trait you support, change the contents of your primary view accordingly.

For more about creating a custom keyboard, read Custom Keyboard in App Extension Programming Guide.

Topics

Providing a User Interface for a Custom Keyboard

inputView

The primary view for the input view controller.

Controlling a Custom Keyboard

- advanceToNextInputMode

Switches to the next keyboard in the list of user-enabled keyboards.

- dismissKeyboard

Dismisses the custom keyboard from the screen.

- handleInputModeListFromView:withEvent:

Supports interaction with the list of user-enabled keyboards.

Interacting with a Text Input Object

textDocumentProxy

A proxy to the text input object that the custom keyboard is interacting with.

Obtaining a Supplementary Lexicon

- requestSupplementaryLexiconWithCompletion:

Obtains a supplementary lexicon of term pairs for use in a custom keyboard.

Changing the Primary Language of a Custom Keyboard

primaryLanguage

The primary language for a custom keyboard.

Configuring the Keyboard Behaviors

needsInputModeSwitchKey

A Boolean value indicating whether the keyboard must display an input switcher key.

hasFullAccess

A Boolean value indicating whether the keyboard has full access.

Instance Properties

Relationships

Inherits From

See Also

Custom Keyboard

UITextDocumentProxy

An object that provides textual context to a custom keyboard.

UIInputViewAudioFeedback

A property that enables a custom input or keyboard accessory view to play standard keyboard input clicks.

UILexicon

A read-only array of term pairs, each in a lexicon entry object, for use by a custom keyboard.

UILexiconEntry

A read-only term pair, available within a lexicon object, for use by a custom keyboard.