The primary view controller for a custom keyboard app extension.
SDKs
- iOS 8.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
Framework
- UIKit
Declaration
class UIInputViewController : UIView Controller
Overview
To create a custom keyboard, first subclass the UIInput
class, then add your keyboard’s user interface to the input
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 theinsert
method on theText(_:) text
property. This property provides that method through its conformance to theDocument Proxy UIKey
protocolInput Delete text in a backward direction, starting at the insertion point, by calling the
delete
method on theBackward() text
property.Document Proxy Switch to another keyboard in the set of user-enabled keyboards, by calling the
advance
method.To Next Input Mode() Dismiss the keyboard, by calling the
dismiss
method.Keyboard()
Obtain textual context around the insertion point by reading the text
properties document
and document
. To find out if the current text input object is empty, call the has
method on the text
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 UIText
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 UIKeyboard
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.