---
title: "如何实现点击UIWebView中链接调用Safari打开目标链接"
author: "sinaier"
date: "2011-10-24T11:05:41Z"
tags: ["Scheme"]
categories: ["移动开发"]
slug: "uiwebview-safari"
draft: false
lastmod: "2011-10-24T11:05:41Z"
id: 1209474
url: "https://sinaier.iteye.com/blog/1209474"
---

-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType;
{
    NSURL *requestURL =[ [ request URL ] retain ];
    if ( ( [ [ requestURL scheme ] isEqualToString: @"http" ] || [ [ requestURL scheme ] isEqualToString: @"https" ] || [ [ requestURL scheme ] isEqualToString: @"mailto" ])
        && ( navigationType == UIWebViewNavigationTypeLinkClicked ) ) {
        return ![ [ UIApplication sharedApplication ] openURL: [ requestURL autorelease ] ];
    }
    [ requestURL release ];
    return YES;
}