1

I am wondering if there is something already like this out there. But I basically want something like UITextView to display text with embedded links. However, I want to be able to handle the URL clicks as a delegate.

I've read a few posts like the following:

How to intercept click on link in UITextView?

However, I really don't want to override the openURL method. My app works with lots of webServer data, and I don't want to keep creating exceptions for different hosts in the openURL method.

I guess my questions is, is there another way to intercept the click on UITextView?

My alternative is to write my own, with a UIScrollView, and use a TTTAttributedLabel (https://github.com/mattt/TTTAttributedLabel) inside it. But am looking for suggestions, or alternatives.

Thanks.

Community
  • 1
  • 1
Yenyi
  • 419
  • 5
  • 19

1 Answers1

1

You may use UIWebView + Local HTML instead of UITextView.

And use the -(BOOL )webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType )navigationType delegate to handle the URL clicks,like:

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

  NSURL * clickedURL=[request URL];

  //Do something here.

  return NO;

}
PeakJi
  • 1,547
  • 14
  • 23