美文网首页
Text编程指南(for iOS):简介

Text编程指南(for iOS):简介

作者: bobociel | 来源:发表于2017-06-19 14:37 被阅读58次

    Introduction

    About Text Handling in iOS

    The iOS platform gives you many ways to display text in your apps and let users edit that text. It also lets you display formatted text and web content in your app’s views. The resources at your disposal range from framework objects—such as text views, text fields, and web views—to text layout engines that you can use directly to draw, lay out, and otherwise manage text.

    iOS 平台提供了多种方式让我们可以在程序中显示和编辑文本。它也支持在应用程序的视图中显示格式文本和web内容。我们可以使用framework框架中的资源(如TextView,TextField,WebView)来布局,绘制,管理文本。

    With the classes in 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 apps.

    我们可以编辑文本输入菜单(添加自定义菜单栏),自定义文本输入框,在应用程序之间进行数据的复制,剪切,拷贝。

    Note: This document was previously titled Text, Web, and Editing Programming Guide for iOS.
    提示:该文档之前的标题是Text, Web, and Editing Programming Guide for iOS。

    At Glance(概览)

    Apps in iOS have a number of powerful technologies to handle text, both for editing text and for rendering high-quality typographically formatted text.

    iOS中的应用程序有许多强大的技术来处理文本,无论是编辑文本还是渲染高质量的排版格式的文本。

    The UIKit Framework Provides Your App with Text and Web Objects

    You can add ready-made text views, text fields, and labels to your app’s user interface by using instances of the UITextView, UITextField, and UILabel. You can add and configure them programmatically or by using the Interface Builder editor in Xcode. You can also turn a view of your app into a miniature web browser capable of understanding and displaying HTML, CSS, and JavaScript content.

    您可以通过使用UITextView,UITextField和UILabel的实例,将现成的文本视图,文本字段和标签添加到应用程序的用户界面。 您可以通过编程方式或使用Xcode中的Interface Builder编辑器来添加和配置它们。 您还可以将您的应用程序的视图转换成能够理解和显示HTML,CSS和JavaScript内容的微型Web浏览器。

    Relevant Chapters: [Displaying Text Content in iOS], [Typographical Concepts], [Managing Text Fields and Text Views]
    相关章节...

    When Users Edit Text, Your App 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 app can control which keyboard is presented; for example, for a numeric-value field, the app should select the numeric keypad. If the entered or edited text is obscured by the keyboard, the app 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.

    当用户点击网页视图中的文本字段,文本视图或表单字段时,iOS会将键盘动画化为视图。 应用程序可以控制显示哪个键盘; 例如,对于数值字段,应用程序应选择数字键盘。 如果输入或编辑的文字被键盘遮盖,应用程序应调整显示文本的视图,使文本显示在键盘上方。 文本视图,文本字段或网页视图的代理负责验证编辑的文本,并在用户关闭键盘时访问和存储编辑的文本。

    Your App Can Draw and Manage Text Directly

    Underlying the text views in UIKit is a powerful layout engine called Text Kit. If you need to customize the layout process or you need to intervene in that behavior, you can use Text Kit. Text Kit is a set of classes and protocols that provide high-quality typographical services which enable apps to store, lay out, and display text with all the characteristics of fine typesetting, such as kerning, ligatures, line breaking, and justification.
    翻译1:
    UIKit中的文本视图的底层是一个功能强大的布局引擎,名为Text Kit。如果您需要自定义布局过程或者您需要介入该行为,则可以使用Tetx Kit。TextKit是一套类和协议,提供高质量的排版服务,使应用程序可以存储,布局和显示具有精细排版的所有特征的文本,例如字距调整,连字,换行和对齐。
    翻译2:
    Text Kit指的是UIKit框架中用于提供高质量排版服务的一些类和协议,它让程序能够存储,排版和显示文本信息,并支持排版所需要的所有特性,包括字距调整、连写、换行和对齐等。

    For most apps, you can use the high-level text display classes and Text Kit for all their text handling. For smaller amounts of text and special needs requiring custom solutions, you can use alternate, lower level technologies, such as the programmatic interfaces from the Core Text, Core Graphics, and Core Animation frameworks as well as other APIs in UIKit itself.

    对于大多数应用程序,您可以使用高级文本显示类和Text Kit来处理所有文本。对于需要定制解决方案的更少的文本和特殊需求,您可以使用备用的较低级别的技术,例如核心文本,核心图形和核心动画框架的编程接口以及UIKit本身中的其他API。

    To communicate directly with the text-input system of iOS, implement the UITextInput and related protocols and classes. Your app can also make use of technologies for spell checking and regular expressions.

    可以直接与iOS的文本输入系统进行通信,实现UITextInput协议和相关的协议和类。您的应用程序还可以使用拼写检查和正则表达式的技术。

    Relevant Chapter: [Using Text Kit to Draw and Manage Text], [Lower Level Text-Handling Technologies]
    相关章节:...

    Your App 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 and for entering data into an app. 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 app-specific ways. Using UIPasteboard and related classes, an app can copy, cut, and paste data within different locations of itself or between itself and another app. As part of copy-cut-paste operations, the user taps a command on an contextual edit menu; your app manages this menu and can add custom commands to it.

    UIKit框架包括用于在视图中编辑数据并将数据输入到应用程序的编程接口。 自定义输入视图可以替换系统键盘以允许输入特殊数据; 输入框附加视图是系统键盘上方的自定义视图(或自定义输入视图),使用户能够以特定于应用程序的方式影响已编辑的数据。 使用UIPasteboard和相关类,应用程序可以在其本身或其他应用程序的不同位置复制,剪切和粘贴数据。 用户可以在上下文编辑菜单上点击命令如复制剪切粘贴操作; 您的应用程序可管理此菜单,并可以添加自定义命令。

    See Also(参阅)

    The Core Graphics and Core Animation frameworks have some text-handling 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.

    To find out more about the Core Text framework, which is appropriate for developing higher-level text-handling frameworks, read Core Text Programming Guide and Core Text Reference Collection.

    相关文章

      网友评论

          本文标题:Text编程指南(for iOS):简介

          本文链接:https://www.haomeiwen.com/subject/hnjjfxtx.html