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 6658661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:56:22+00:00 2026-05-26T01:56:22+00:00

I have web content inside a UIWebView in my app. My goal is to

  • 0

I have web content inside a UIWebView in my app. My goal is to have all links open normally inside the app, but any links starting with “http://maps”, get opened in safari, so they can in turn be opened in the external iphone maps app. If you have a solution for this problem stop reading now, below I’m going to propose my solution. Currently all links are opened inside the app, so http://maps links open to m.google.com inside the app. The solution I’m thinking of involves this code which uses openURL to open all links in safari:

(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    if (navigationType == UIWebViewNavigationTypeLinkClicked) {
        \[\[UIApplication sharedApplication] openURL:request.URL];
        return false;
    }
    return true;
}

Obviously the problem with this code is that all links are opened in safari, and I only want map links. Can you suggest a way to parse through links and only pass ones that start with http://maps through the function? Also a more simple question, how do I delegate UIWebView so I can run this code, and also is the viewcontroller.m the right place to put this code?

If you guys could suggest an entire function, including the openURL part above and the link parsing to make sure only maps links get passed through the function that would be awesome. Again, if you have another solution or workaround I would love to hear it. Thanks so much for your help, stackoverflow has been a lifesaver, I’m almost finished with my first project ever!

  • 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-05-26T01:56:23+00:00Added an answer on May 26, 2026 at 1:56 am

    Try something like this:

    -(BOOL)webView:(UIWebView *)inWeb
    shouldStartLoadWithRequest:(NSURLRequest *)request
    navigationType:(UIWebViewNavigationType)inType {
      // let UIWebView deal with non-click requests
      if (inType != UIWebViewNavigationTypeLinkClicked) {
        return YES;
      }
    
      // URL starts with "http://maps"?
      if ([[request.URL description] hasPrefix:@"http://maps"]) {
        // open URL in Safari and return NO to prevent UIWebView from load it
        [[UIApplication sharedApplication] openURL:[request URL]];
        return NO;
      }
    
      // otherwise let UIWebView deal with the request
      return YES;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web app where people can create custom content on the web
I have a resources web app, which only has static content, such as images,
I have a Web content form and need to access a control inside the
The commercial web app I am developing resides inside an SSL environment. I have
I have read several articles regarding templates for web site content. They all seem
Today I realized that I no longer have a Web Content Form option (where
I have a asp.net web content from that have a asp.net textbox and I
I have a web application that has a page that loads the content from
Say I have a web service where I want to serve the content only
Let's say I have a web site for hosting community generated content that targets

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.