gpt4 book ai didi

iphone - UITextInput 的 Tokenizer,它是做什么用的?

转载 作者:可可西里 更新时间:2023-11-01 04:47:22 27 4
gpt4 key购买 nike

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

最佳答案

它用于键盘导航(当您连接了硬件键盘时)。例如,在按住 Option 并使用箭头键的同时在单词之间导航,转到行的开始/结束。

摘自 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. 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.

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

关于iphone - UITextInput 的 Tokenizer,它是做什么用的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16335518/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com