首页 > 代码库 > iOS 第三方应用调用safari

iOS 第三方应用调用safari

一,直接调用safari打开url

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

 

二,通过webView设置代理在内部打开

     如果当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;
}

iOS 第三方应用调用safari