如何实现点击UIWebView中链接调用Safari打开目标链接

如何实现点击UIWebView中链接调用Safari打开目标链接

  1. -(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType;
  2. {
  3.     NSURL *requestURL =[ [ request URL ] retain ];
  4.     if ( ( [ [ requestURL scheme ] isEqualToString: @"http" ] || [ [ requestURL scheme ] isEqualToString: @"https" ] || [ [ requestURL scheme ] isEqualToString: @"mailto" ])
  5.         && ( navigationType == UIWebViewNavigationTypeLinkClicked ) ) {
  6.         return ![ [ UIApplication sharedApplication ] openURL: [ requestURL autorelease ] ];
  7.     }
  8.     [ requestURL release ];
  9.     return YES;
  10. }
0

这篇文章还没有评论

发表评论