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;
}
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。