About Text, Web, and Editing Support in iOS

iOS gives you many ways to display text in your applications and let users edit that text. It also lets you display web content in your application’s views. The resources at your disposal range from framework objects such as text fields and web views to lower-level technologies that allow your application to draw, lay out, and otherwise manage text.

With the facilities of the UIKit framework, you can manage the edit menu (including adding custom items to it), implement custom input views, and copy, cut, and paste data within and between applications.

image: ../Art/multistage_text.jpg

At a Glance

The UIKit Framework Provides Your Application with Text and Web Objects

Instances of the UITextView, UITextField, and UILabel classes serve as ready-made text views, text fields, and labels that you can add to your application’s user interface. You can add and configure them programmatically or by using the Interface Builder application. A UIWebView object can turn a view of your application into a miniature web browser capable of understanding and displaying HTML, CSS, and JavaScript content

When Users Edit Text, Your Application Must Manage the Keyboard

When a user taps a text field, text view, or form field in a web view, iOS animates a keyboard into view. An application can control which keyboard is presented; for example, for a numeric-value field, the application should select the number-pad keyboard. If the entered or edited text is obscured by the keyboard, the application should adjust the view displaying the text so that the text appears above the keyboard. The delegate of a text view, text field, or web view is responsible for validating edited text and for accessing and storing edited text when the user dismisses the keyboard.

Your Application Can Draw and Manage Text on Its Own

Instead of using the UIKit classes for displaying and and editing text, you could choose to implement an application that does simple text drawing or text input, or even one with its own text layout and management engine. For assistance in text layout and font management, use the Core Text framework. To communicate with the text-input system of iOS, implement the UITextInput protocol and related protocols and classes. Your application can also make use of technologies for spell-checking and regular expressions.

Your Application Has a Range of Options for the Input and Editing of Data

The UIKit framework includes programmatic interfaces for editing the data in a view as well as entering data into an application. Custom input views can replace the system keyboard to permit input of special data; input accessory views are a custom view above the system keyboard (or custom input view) that enables users to affect edited data in application-specific ways. Using the facilities of the UIPasteboard and related classes, an application can copy, cut, and paste data within different locations of itself or between itself and another application. As part of copy-cut-paste operations, the user taps a command on an contextual edit menu; your application manages this menu and can add custom commands to it.

See Also

If your application is going to do sophisticated text entry and management, it should use the Core Text technology; read Core Text Programming Guide to learn about Core Text.

The Core Graphics and Core Animation frameworks also have text capabilities. Core Animation, for example, offers the CATextLayer class. To learn more about these capabilities, read Quartz 2D Programming Guide (Core Graphics) and Core Animation Programming Guide.


Did this document help you? Yes It's good, but... Not helpful...