gpt4 book ai didi

ios - 如何将 UITextView 中的字符分组为单个字符

转载 作者:行者123 更新时间:2023-11-30 13:57:50 25 4
gpt4 key购买 nike

在我的 UITextView 中,我希望将某些单词视为“分块”或“片段”:

  1. 无法在单词中间选择
  2. 如果退格则会删除整个单词

Facebook 撰写帖子屏幕就是一个很好的例子,它允许您提及 Facebook 好友,但如果您尝试删除提及内容,整个名字都会消失,而不仅仅是一个字母。

在所有文本工具包和核心文本类中,是否有一个非常适合此用例?

最佳答案

我想您可以使用NSTextAttachments,因为它们被视为单个字符。这是我在文档中找到的内容:-

A text attachment object contains an NSFileWrapper object, which in turn holds the contents of the attached file. It also uses a cell object conforming to the NSTextAttachmentCell protocol to draw and handle mouse events. Most of the behavior of a text attachment is relegated to the file wrapper and the attachment cell. See the corresponding class and protocol specifications for more information.

您也可以使用它在 TextView 文本中添加小图像。

关于ios - 如何将 UITextView 中的字符分组为单个字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33384451/

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