Contents

UIInputViewController

The primary view controller for a custom keyboard app extension.

Declaration

@MainActor class UIInputViewController

Mentioned in

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:

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

Controlling a custom keyboard

Interacting with a text input object

Obtaining a supplementary lexicon

Changing the primary language of a custom keyboard

Configuring the keyboard behaviors

See Also

Custom keyboard