Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
305 views
in Technique[技术] by (71.8m points)

iphone - UILabel touch and get the text where touched

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I think you'll find what you're looking for in the documentation for UITextInputProtocol.

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's references a sample projected called SimpleTextInput, but I can't seem to find it. I'll keep looking.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...