title: iPhone:UIWebview open hyperlink in safari
body: <p>In my app,I used UIwebview where I need to hyperlink some phone numbers,email &amp; URLs.I did the following:</p>
  
  <pre><code> - (void)viewDidLoad
      {
          credits.delegate=self;
      }
  
  
  
  -(void)loadScreen
  {
  scroll=[[UIScrollView alloc]init];
   credits=[[UIWebView alloc]init];
  
  NSString *Address = @"www.***.com/php/getjson.php?method=";
  
  
      jmax = [NSURL URLWithString:Address];
  
      NSData *Data =[ NSData dataWithContentsOfURL:jmax];
  
  
      String = [[NSString alloc] initWithData:Data encoding:NSUTF8StringEncoding];
  
      NSString * creditsHtml = [NSString stringWithFormat:@" &lt;font face=\"Arial\"&gt;&lt;H3 align=\"center\"&gt; Credits &lt;/H3&gt; %@ &lt;br&gt;Phone%@&lt;/font&gt;", String,phone];
  
      credits.userInteractionEnabled = YES;
      credits.frame=CGRectMake(10, (frame1.size.height + 564), 300, 100);
      credits.dataDetectorTypes=UIDataDetectorTypeAll;
      credits loadHTMLString:creditsHtml baseURL:nil];
  
  [scroll addSubview:credits];
  }
  
  
  
     -(BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType{
  
  
          NSString *urls=  jmaxString;
  
          NSURL *requestURL =[NSURL URLWithString: urls]; 
          if ( ( [ [ requestURL scheme ] isEqualToString: @"http" ] || [ [ requestURL scheme ] isEqualToString: @"https" ] || [ [ requestURL scheme ] isEqualToString: @"mailto" ] ) 
              &amp;&amp; ( navigationType == UIWebViewNavigationTypeLinkClicked ) ) { 
              return ![ [ UIApplication sharedApplication ] openURL: requestURL ]; 
          } 
  
          return YES; 
      }
  </code></pre>
  
  <p>Edited shouldStartLoadWithRequest: method</p>
  
  <pre><code>-(BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType{
  
      NSURL *requestURL =[request URL];
  
      if ( ( [ [ requestURL scheme ] isEqualToString: @"http" ] || [ [ requestURL scheme ] isEqualToString: @"https" ] || [ [ requestURL scheme ] isEqualToString: @"mailto" ] ) 
          &amp;&amp; ( navigationType == UIWebViewNavigationTypeLinkClicked ) ) { 
          return ![ [ UIApplication sharedApplication ] openURL: requestURL ]; 
      } 
      NSLog(@"URL %@",requestURL);
  
  
      return YES; 
  }
  </code></pre>
  
  <p>Got error in <code>NSURL *requestURL =[request URL];</code> with <code>Expected ; at the end</code> &amp; <code>Extraneous ')' before ';'</code></p>