Open the Apple Maps iOS6 app from a link in UIWebView

If I show a map link on a web page

<a href="http://maps.apple.com/?q=Pricketts+Hill+Southampton+Hampshire+SO32+2JW&ll=50.913127,-1.191398">Location</a>

it opens its own Apple Maps iOS6 app when clicked in the standard iPhone Safari browser. When I display the same webpage in a UIWebView inside my application, and then click the link, my delegation method

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {

and parameters

url=http://maps.apple.com/?q=Pricketts+Hill+Southampton+Hampshire+SO32+2JW&ll=50.913127,-1.191398
navigationType=UIWebViewNavigationTypeLinkClicked

If the delegate method returns YESto indicate that the UIWebView should go ahead and open the link, a new delegate call is invoked immediately, and this time the parameters

url=http://maps.google.com/?q=Pricketts+Hill+Southampton+Hampshire+SO32+2JW&ll=50.913127,-1.191398 
navigationType=UIWebViewNavigationTypeLinkClicked

YES , , - maps.google.com UIWebView. , iOS6 Apple Maps . CLGeocoder MKMapItem URL- iOS Maps iOS 6?, CLGeocoder , , URL , . URL- - , Mobile Safari, , UIWebView Safari .

UIWebView Apple Maps iOS6 URL?

, delegate URL- maps.google.com, :

url=about:blank 
navigationType=UIWebViewNavigationTypeOther

. , ?

+5
1

, maps.apple.com Maps UIWebview. , UIWebview , . webView: shouldStartLoadWithRequest: navigationType: :

if (([url.scheme isEqualToString:@"http"] || [url.scheme isEqualToString:@"https"]) && [url.host isEqualToString:@"maps.apple.com"]) { //it an apple maps app request
    NSLog(@"Attempting Apple Maps app open");
    [[UIApplication sharedApplication]openURL:url];
    return NO;
}

Apple Maps iOS6. iOS5 - google maps Safari. iOS5 URL - .

+4

All Articles