Pre Exam Test Practice
Ask a Question
Advertise on boostr.in
Organizational Research By
Surprising Reserch Topic
getting the word touched in a uilabel uitextview
getting the word touched in a uilabel uitextview ¬†using -'ios,text,word,touch,uilabel'
What I'd like to do is to create a text-container component that is able to indicate what is the nearest word when there's is a touch on it (i.e. the word "behind" the touched point).
First, I created a UILabel subclass and overrode the touchesEnded:withEvent: method to determine the touched CGPoint. I also wrote a method that compute the corresponding "frame" (CGRect) of each word of the text using sizeWithFont:forWidth:lineBreakMode:. With the touched CGPoint and this frame, I can determine which word is actually being touched. But the method that compute the frame only works with mono-line text.
So now I need to know which part of the text is on a given line (i.e. how the text has been splited), so that I can figure the correct left-margin and top-margin of each word.
Any idea how I can obtain this?
Or maybe have you a more straightforward solution to achieve this? This post was unfortunately not very helpful......
Sep 16, 2015
to add a comment.
Related Hot Questions
Government Jobs Opening