Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7754891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:25:41+00:00 2026-06-01T12:25:41+00:00

Thanks for viewing my question. Let me describe the app first. I have a

  • 0

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).

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.

In my FirstViewController.m file (which is same in the other views), I have…

    - (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;
}  

Which works fine if I want the URL to open in Safari. So in this part…

//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;
    }

I need it to open a modal view with the clicked URL, not Safari.

So what I’m asking is…
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?

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.

I can load the modal via the line…

[self performSegueWithIdentifier:@"ModalWebView" sender:self];

but that just loads it without any URL info and a blank webview, of course. The modal uses WebViewController.h/m.

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?

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.

Thank you for your time and patience.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:25:42+00:00Added an answer on June 1, 2026 at 12:25 pm

    In your view controller, implement the prepareForSegue method and add the following code.

    -(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    
        NSLog(@"Source Controller = %@", [segue sourceViewController]);
        NSLog(@"Destination Controller = %@", [segue destinationViewController]);
        NSLog(@"Segue Identifier = %@", [segue identifier]);
    
        if ([segue.identifier isEqualToString:@"ModalWebView"]) {
    
            ModalWebViewController *wVC = [segue destinationViewController];
            wVC.url = [NSURL URLWithString:article.url]; // replace article.url with your url.
        }
    
    }
    

    In my code above, the URL that will be used is set from my article.url object. To get this to work, you need to get the url from the method shouldStartLoadWithRequest.

    // CurrentViewController.h
    @property (strong, nonatomic) NSURL *targetUrl;
    
    // CurrentViewController.m 
    //If it's an external link...
        if ([[URL scheme] isEqualToString:@"http"] || 
            [[URL scheme] isEqualToString: @"https" ])  {
            targetUrl = url;
            [self performSegueWithIdentifier:@"ModalWebView" sender:self];
            return NO;
        }
    

    If using the above, we now replace article.url in the first code block with targetUrl.

    if ([segue.identifier isEqualToString:@"ModalWebView"]) {
    
                ModalWebViewController *wVC = [segue destinationViewController];
                wVC.url = targetUrl; 
            }
    

    In your view controller for your modal web view.h file create a NSURL.

    //ModalWebViewController.h
    @property (strong, nonatomic) NSURL *url;
    

    In your implementation file (.m) create the method viewDidAppear

    //ModalWebViewController.m 
    -(void) viewDidAppear:(BOOL)animated {
        [_webView loadRequest:[NSURLRequest requestWithURL:url]];
    }
    

    Hope I’ve explained that enough for you to be able to implement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Thanks for viewing my question. So, I have a question with iframes. I want
First time using this service for a question. I hope I am not asking
quick question - I have my first view which is going to be the
I am new to ASP.NET MVC and I have a question regarding viewing entity
Hey, first of all thanks for helping me out with this (probably stupid) question
Thanks for viewing my question. I'm new to web development and was hoping someone
Hello everyone and thanks for viewing this question :) I am an indie to-be-developer
I am using spring mcv with ibatis and jsp for viewing. my question is
In my first attempt at an MVC web application I have a fundamental question:
Thanks for looking at my question. I am looking to have a London information

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.