UIText object manages bar button items displayed in the shortcuts bar above the keyboard on iPad. Use this object to add app-specific actions to the shortcuts bar. The center of the shortcuts bar displays typing suggestions for the user. You can install custom bar button items that lead or trail the typing suggestions.
- iOS 9.0+
You do not create instances of this class directly. Instead, you get an input assistant from the
input property of the responder object whose keyboard you want to modify. When the keyboard is displayed, UIKit automatically searches the responder chain for a text input assistant object. Typically, you assign the text input assistant to the object that becomes the first responder, but you may also assign it to a parent responder object in order to share a set of shortcuts among multiple children.
The bar button items you create for the shortcuts bar must be organized into groups. A
UIBar object manages each group of items, and each group may contain a single item or several items. UIKit displays as many items as possible based on the available space. When there is not enough space for all of the items, UIKit collapses each group of items down to a single representative item to make more space.
Listing 1 shows a code snippet for configuring the items of the shortcuts bar. After creating the bar button items, this code creates a group and assigns that group to the
leading property. The resulting items are displayed before the typing suggestions.
To hide shortcuts altogether, set the
trailing properties to
nil. Doing so hides only the shortcuts and does not hide the typing suggestions. To hide typing suggestions, you must also set the
autocorrection property of the responder that displays the keyboard to