iOS 第三方應用調用safari

一,直接調用safari打開urlhtml

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.2cto.com/kf/201211/171644.html"]]; web

 

二,經過webView設置代理在內部打開url

     若是當webView內部打開連接時用safari
     固然這必須委託給本身
      webView.delegate=self;
     也固然要加
     <UIWebViewDelegate>
這樣就會自動調用該方法了
-(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;
}
spa

相關文章
相關標籤/搜索