简体   繁体   English

UITextInput的Tokenizer,它用于什么?

[英]Tokenizer of UITextInput, what is it used for?

我正在实现一个自定义文本输入视图,它采用UITextInput协议,当使用UITextView ,双击一个单词使单词被选中,我想知道UITextInput如何使用它的标记化器来标记字符串,到现在UITextInput我没有看到任何区别或者不通过覆盖[UITextInput -tokenizer]方法为UITextInput分配tokenizer。

It is used for things like keyboard navigation (when you have a hardware keyboard connected). 它用于键盘导航(当您连接了硬件键盘时)。 For example, navigating between words while holding Option and using the arrow keys, going to start / end of line. 例如,在按住Option并使用箭头键的同时在单词之间导航,转到行的开头/结尾。

From Apple's Text Programming Guide for iOS: 来自Apple的iOS文本编程指南:

Tokenizers are objects that determine whether a text position is within or at the boundary of a text unit with a given granularity. 标记符是确定文本位置是否在具有给定粒度的文本单元的边界内或边界处的对象。 When queried by the text input system, a tokenizer returns ranges of text units with a given granularity or the boundary text position for a text unit with a given granularity. 当由文本输入系统查询时,标记化器返回具有给定粒度的文本单元的范围或具有给定粒度的文本单元的边界文本位置。 Currently defined granularities are character, word, sentence, paragraph, line, and document; 当前定义的粒度是字符,单词,句子,段落,行和文档; enum constants of the UITextGranularity type represent these granularities. UITextGranularity类型的枚举常量表示这些粒度。 Granularities of text units are always evaluated with reference to a storage or layout direction. 始终参考存储或布局方向评估文本单元的粒度。

The text input system uses the tokenizer in a variety of ways. 文本输入系统以各种方式使用标记器。 For example, the keyboard might require the last sentence's worth of context to figure out what the user is trying to type. 例如,键盘可能需要最后一句话的上下文来确定用户尝试键入的内容。 Or, if the user is pressing the Option-left arrow key (on an external keyboard), the text system queries the tokenizer to find the information it needs to move to the previous word. 或者,如果用户按下Option-left箭头键(在外部键盘上),文本系统将查询tokenizer以查找移动到上一个单词所需的信息。

More: https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/LowerLevelText-HandlingTechnologies/LowerLevelText-HandlingTechnologies.html 更多: https//developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/LowerLevelText-HandlingTechnologies/LowerLevelText-HandlingTechnologies.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM