当前位置: 代码迷 >> Web前端 >> 怎么实现点击UIWebView中链接调用Safari打开目标链接
  详细解决方案

怎么实现点击UIWebView中链接调用Safari打开目标链接

热度:102   发布时间:2012-09-29 10:30:01.0
如何实现点击UIWebView中链接调用Safari打开目标链接
-(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;
}
  相关解决方案