UILabel触摸并获取触摸的文本 [英] UILabel touch and get the text where touched
问题描述
我的UILabel有一些文字和2个月的名字,如在1月和7月,阳光照耀将达到峰值
我分类UILabel并添加触摸事件。
现在我想在用户触摸的文本下面找到这个词,并找出用户是否触及1月/ 7月。有可能吗?
I've UILabel which has some text and 2 month names like "In the month of January and July, sun shine will be peak" I sub classed UILabel and added touch event to it. Now I want to get the word below the text where user touched and find out whether user touched January/July or not. Is it possible?
推荐答案
我想你会在 UITextInputProtocol 。
有关更多高级别信息,请查看Apple的文本,Web和编辑指南,特别是在标题为UITextInput实现的指导教程的部分中。它讨论了如何在文本中创建索引位置,并询问他们最接近的文本位置。
For some more high level information, check out Apple's Text, Web and Editing Guide, specifically in the section titled "A Guided Tour of a UITextInput Implementation". It discusses how you can create indexed positions in text, and ask touches what text position they've landed nearest.
Apple引用了一个名为的预测样本SimpleTextInput
,但我似乎无法找到它。我会继续寻找。
Apple's references a sample projected called SimpleTextInput
, but I can't seem to find it. I'll keep looking.
这篇关于UILabel触摸并获取触摸的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!