Make links inside a UIWebView clickable

suggest change

In vc.h

@interface vc : UIViewController<UIWebViewDelegate>

in vc.m

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
    if (navigationType == UIWebViewNavigationTypeLinkClicked){
        // Open the link in the browser. To load it in this web view, remove the return NO.
        NSURL *url = request.URL;
        if ([[UIApplication sharedApplication] canOpenURL:url]) {
            [[UIApplication sharedApplication] openURL:url];
        }
        return NO;
    }
    return YES;
}

Set the web view’s delegate to this controller, or the method is never called. openURL: is the pre-iOS 10 call. iOS 10 and later use openURL:options:completionHandler:.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents