A set of methods you implement to interact with the text input system and enable features such as autocorrection and multistage text input in documents.
- iOS 3.2+
- tvOS 9.0+
Objects of classes that adopt the
UIText protocol provide the text input system with text positions and text ranges on demand, answer questions about layout and writing direction, perform hit-testing—that is, returning text positions and ranges for a given point—and provide the system with rectangles that can be used for highlighting ranges of text and drawing the caret. In addition, a
UIText object maintains ranges for selected text and marked text.
Marked text, which is part of multistage text input, represents provisionally inserted text that the user has yet to confirm. It is styled in a distinctive way. The range of marked text always contains within it a range of selected text, which might be a range of characters or the caret.
(Multistage text input is required when the language is ideographic and the keyboard is phonetic.)
UIText protocol is the center of a constellation of classes and protocols for integrating text-processing applications with the text input system. The other parts of this constellation are the following:
UIText-conforming document classes must create custom subclasses of these classes. A
UITextobject represents a position in a text container. A
UITextobject, which encapsulates beginning and ending
UITextobjects, represents a range of characters in the text container.
UITextclass—The protocol defines an interface for a tokenizer object that enables the text input system to evaluate text units of different granularities. The class is a default implementation of this protocol.
Input String Tokenizer
UITextprotocol—The text input system automatically assigns its own text input delegate (which conforms to this protocol) to the
UIText-conforming document object. Through this text input delegate, a document object informs the text input system of changes in text and selection.
UIKeyprotocol—Implemented to acquire the capabilities of text entry and deletion at an insertion point.
UIText protocol also inherits the
UIText protocol, and thus the ability to customize the keyboard and its behaviors.
When the user chooses dictation input on a supported device, the system automatically inserts recognized phrases into the current text view. Methods in the
UIText protocol allow your app to respond to the completion of dictation, as described in Using Dictation. You can use an object of the
UIDictation class to obtain a string representing a phrase a user has dictated. In the case of ambiguous dictation results, a dictation phrase object provides an array containing alternative strings.