作者:陈雅杰昱宏 | 来源:互联网 | 2023-07-27 12:01
InmyiOSkeyboardextension,Ihaveafunctionthatmovesthecursorbackwardsasfollows:在我的iOS键
In my iOS keyboard extension, I have a function that moves the cursor backwards as follows:
在我的iOS键盘扩展中,我有一个向下移动光标的功能,如下所示:
(textDocumentProxy).adjustTextPositionByCharacterOffset(-1)
and displays the words right before the cursor in a UILabel using the textDocumentProxy.documentContextBeforeInput
function provided by Apple. The problem is, whenever an emoji appears inside the label, it starts being separated as such:
并使用Apple提供的textDocumentProxy.documentContextBeforeInput函数在UILabel中显示光标前的单词。问题是,只要表情符号出现在标签内部,它就会开始分离:
Is there any way of avoiding this? Does it have anything to do with me hardcoding the -1? I've tried using str.utf16.count
but that just doesn't scroll at all for some reason. Any help would be greatly appreciated.
有没有办法避免这种情况?这与我硬编码-1有什么关系吗?我已经尝试过使用str.utf16.count但由于某种原因根本不滚动。任何帮助将不胜感激。
Here's my question from a few months ago that never got answered
这是我几个月前的问题,从来没有得到答案
1 个解决方案