UIWebView Link Click

PgmFreek picture PgmFreek · Mar 9, 2011 · Viewed 32.8k times · Source

In my app certain HTML page is loaded in a webview. I need to get click on certain label like "neuron" and should display their description in another view. How Can i get the label click and clicked label in the webview?

Answer

Franky picture Franky · Aug 20, 2013

Use the Delegate to Determine the Navigation Type!

My Snippet

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


    if (navigationType == UIWebViewNavigationTypeLinkClicked){

        NSURL *url = request.URL;
        [self openExternalURL:url];//Handle External URL here

    }

    return YES;

}