Is there a way to count words in a single line of UITextView provided that UITextView has frame? I know the text size, the frame size, and I can get number of lines but I don't know how I can get number of words in each line.
Asked
Active
Viewed 417 times
1
-
If you can extract a line of text, the rest is easy. – Evan Mulawski May 28 '12 at 15:35
-
Will it be enough to count all the words through this solution: http://stackoverflow.com/questions/3975209/what-is-the-most-efficient-way-to-count-number-of-word-in-nsstring-without-using and divide by the number of lines? – tiguero May 28 '12 at 16:36
-
Wouldn't I get just an avarage number of words per line no exact one? – Ertai May 28 '12 at 16:53
-
How can I extract just single line of text from UITextView? – Ertai May 28 '12 at 16:53
-
I agree: it gives you an average number of words but you can use this info to estimate where your linebreak should occur by removing or adding a word to a set of words you want to associate to a line and check if it generates a new line or not. For extracting a line of text someone seems to investigate here: http://stackoverflow.com/questions/2450339/content-of-a-specific-line-in-uitextview by adding a category: not sure it works though but you could give it a try. – tiguero May 28 '12 at 17:22