Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Add this to the UIWebView delegate:</p> <p>(edited to check for navigation type. you could also pass through <code>file://</code> requests which would be relative links)</p> <pre><code>- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { if (navigationType == UIWebViewNavigationTypeLinkClicked ) { [[UIApplication sharedApplication] openURL:[request URL]]; return NO; } return YES; } </code></pre> <p>Swift Version:</p> <pre><code>func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -&gt; Bool { if navigationType == UIWebViewNavigationType.LinkClicked { UIApplication.sharedApplication().openURL(request.URL!) return false } return true } </code></pre> <p>Swift 3 version:</p> <pre><code>func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -&gt; Bool { if navigationType == UIWebViewNavigationType.linkClicked { UIApplication.shared.openURL(request.url!) return false } return true } </code></pre> <p><strong><em>Update</em></strong></p> <p>As <code>openURL</code> has been deprecated in iOS 10:</p> <pre><code>- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { if (navigationType == UIWebViewNavigationTypeLinkClicked ) { UIApplication *application = [UIApplication sharedApplication]; [application openURL:[request URL] options:@{} completionHandler:nil]; return NO; } return YES; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload