就用這就能打開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;
}