iOS 第三方应用调用safari
就用这就能打开safari;
NSURL* url = [[ NSURL alloc ] initWithString :@"http://www.baidu.com"];
[[UIApplication sharedApplication ] openURL: [url autorelease ]];
如果当webView内部打开链接时用safari
当然这必须委托给自己
webView.delegate=self;
也当然要加 www.2cto.com
<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;
}
相关新闻>>
- 发表评论
-
- 最新评论 更多>>