Clicking a word in a UITextView

I want to allow users to enter text in the iPhone app, and when they touch a word or sentence, call the method for that word.

My problem is how to do this?

I got an idea from the AudioNote application: http://luminantsoftware.com/iphone/audionote.html

Does anyone know how to do this?

+4
source share
2 answers

It looks like they can use UIWebView to display text. This gives you the advantage that you can apply different formatting to individual words.

To handle clicking on words, you could create them as hyperlinks and detect touches using:

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType 

** oops, sorry, forgot about entering text. I don’t know how to do this with web browsing.

+1
source

What do you mean by "calling a method for this word"?

Wherever I start looking will be in the UITextView documentation and the UITextViewDelegate documentation

If I understand what you want to do, you can do it using the UITextViewDelegate method

 - (void)textViewDidChangeSelection:(UITextView *)textView 
0
source

Source: https://habr.com/ru/post/1339879/


All Articles