UITextInputAssistantItem
An object that manages custom bar button items that you add to the shortcuts bar above the keyboard on iPad.
Declaration
@MainActor class UITextInputAssistantItemOverview
Use a UITextInputAssistantItem object to add app-specific actions to the shortcuts bar on iPad. 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.
You don’t create instances of this class directly. Instead, you get an input assistant from the inputAssistantItem property of the responder object whose keyboard you want to modify. When the keyboard is onscreen, 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. However, you can also assign it to a parent responder object to share a set of shortcuts among multiple children.
Organize the bar button items you create for the shortcuts bar into groups. A UIBarButtonItemGroup 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’s not enough space for all of the items, UIKit collapses each group of items down to a single representative item.
The following code configures the items of the shortcuts bar. After creating the bar button items, this code creates a group and assigns that group to the leadingBarButtonGroups property. The resulting items appear before the typing suggestions.
To hide shortcuts altogether, set the leadingBarButtonGroups and trailingBarButtonGroups properties to empty arrays. Doing so hides only the shortcuts and doesn’t hide the typing suggestions. For information on managing the typing suggestions, see autocorrectionType.