title: Within a (BOOL)webView: How to open a URL clicked in UIWebView that opens a Modal UIWebView
body: <p>Thanks for viewing my question. Let me describe the app first. I have a tab bar based app for iOS5.1 that is using storyboard and ARC. There are four tabs with a view controller in each one that shows a webview with local HTML files (each view is a different set of html files to display).</p>
  
  <p>Currently when a user touches a http or https link, it'll open in Safari. However, I now want it to open within app via a modal view. I currently have the interface created and ready to show, but I can't pass the URL to the modal's "webview2". I've looked for many examples to do this using RSURL and strings and etc, but can't get any of them to work. Some of the example code given didn't seem to work for my situation.</p>
  
  <p>In my FirstViewController.m file (which is same in the other views), I have...</p>
  
  <pre><code>    - (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
  
      //Gets the link.
      if (navigationType == UIWebViewNavigationTypeLinkClicked) {
          NSURL *URL = [request URL]; 
          NSLog(@"url:%@",request); //Get's the url itself
  
          //If it's an external link...
          if ([[URL scheme] isEqualToString:@"http"] || 
              [[URL scheme] isEqualToString: @"https" ])  {
              [[UIApplication sharedApplication] openURL:[request URL]];
              NSLog(@"Opened in Safari");
              return NO;
          }
  
          //If it's an email address...
          else if ([[URL scheme] isEqualToString:@"mailto"]) {
              [webView loadRequest:request];
              [[UIApplication sharedApplication] openURL:[request URL]];
              NSLog(@"Opened in Mail App");
              return NO;
          }
      }        
      return YES;
  }  
  </code></pre>
  
  <p>Which works fine if I want the URL to open in Safari. So in this part...</p>
  
  <pre><code>//If it's an external link...
      if ([[URL scheme] isEqualToString:@"http"] || 
          [[URL scheme] isEqualToString: @"https" ])  {
          [[UIApplication sharedApplication] openURL:[request URL]];
          NSLog(@"Opened in Safari");
          return NO;
      }
  </code></pre>
  
  <p>I need it to open a modal view with the clicked URL, not Safari.</p>
  
  <p>So what I'm asking is...
  <strong>What is the best way to get this URL saved, then open the modal view and then in the modal webview open the URL that was just touched?</strong></p>
  
  <p>I already have the modal view made with a dismiss button and etc. I just need it to load with the clicked URL when it loads.</p>
  
  <p>I can load the modal via the line...</p>
  
  <pre><code>[self performSegueWithIdentifier:@"ModalWebView" sender:self];
  </code></pre>
  
  <p>but that just loads it without any URL info and a blank webview, of course. The modal uses WebViewController.h/m.</p>
  
  <p>If anyone could tell me how to open and pass on the URL so it loads in the segue "ModalWebView", I would appreciate it. Please let me know if I need to make any properties or anything else that I should include in my WebViewController.h/m that runs the modal view. Maybe -(void)prepareForSegue needs to be used? If so, how?</p>
  
  <p>I realize the answer maybe simple, but I'm still a beginner and have spent days trying to find a clear answer. I've found answers to much of my questions on this site by searching before, but I'm afraid I'm stuck on this one.</p>
  
  <p>Thank you for your time and patience.</p>