I have a UIWebView in my application that loads a mobile website. The mobile website then has lots of different links.
One of those links will try and load a map using Google Maps.
Initially, I had a problem where the user clicked the maps link, as the application would try to load the maps inside my webview. What this does, is make the user stuck, as once you’ve loaded maps inside the webview, there’s no way to go back.

The only way for you to the go back, is by force closing the application, so not ideal.
I then found other people having the same problem, and implemented the solution as described here.
This worked great, and now upon clicking the map link, it opens up the maps application. In order to go back to the original application, I can simply double tap the home button, and select my application on the list of running applications.
However, this brought another problem. When I select my application again, it briefly displays the contents back, and then opens the following popup:

No matter what you chose there, it then loads up the maps again, but inside of the webview this time, which negates all the work done as described previously.
Has anyone here seen this kind of behaviour, and if so, do you know how to go around it, so it doesn’t even open the popup asking for your current location?
UPDATE
Adding the code I;m using to handle it
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
// URL Starts with "http://maps?"
if([[request.URL description] hasPrefix:@"http://maps"]){
[[UIApplication sharedApplication] openURL:request.URL];
return NO;
}
// otherwise let the webview deal with the request
return YES;
}
Thanks in advance,
based on your additional comments below, i’ve edited this answer to focus on the second solution i had originally proposed:
the .xib would look something like the following … paying special attention to the fact that the done button is last in the subview order so that it can sit on top of the webview if desired (yes, the webview could be made to take up 100% of the superview real estate, and the button could sit on top of it; it just does not in this example app i used) (and ignore the background image; in the example app i used to take this screenshot, it is used behind a partially transparent webview; if this is desired, make sure it appears first in the subview order of the .xib view so that it is “behind” all other subviews).
and the code you would need for this would be in the view controller associated with this .xib, and would look something like the following:
this solution should allow you to stay inside of your app, and then if you do get to the dialog asking for the location, the result should be immediate and apply back only inside of your app.
i know this doesn’t solve the problem the way you’ve stated it, but it might give you the behavior you want.