2013-12-18 36 views
1

首先,我發佈這個,因爲所有其他教程不起作用。 好了,所以這是我的HTML代碼本地蘋果地圖的UIWebView轉診

<a href="http://maps.apple.com/?daddr=1/76+Ferry+Rd,+Southport&saddr=Current+Location">Directions</a>

我有這個問題,以及

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { 
    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; 
    }; 

但每次我點擊上面的鏈接重定向我到google上UIWebView的地圖,但我想它將我重定向到(Apple)地圖應用程序。

+0

檢查可以幫助你http://stackoverflow.com/questions/14521689/open-ios6-apple-maps-app-from-a-鏈接-IN-A-的UIWebView –

+0

@Bhumeshwerkatre我已經看到這一點,它沒有工作對我來說,它只是導致要對谷歌,加上我需要一個以上的鏈接,我需要一噸(如9000) – user3089637

+0

我會也有興趣解決這個問題。最奇怪的是,從鏈接移動版Safari(蘋果打開地圖),而不是從一個應用程序中的網頁視圖(鏈接到谷歌地圖的網頁版)正常工作。 –

回答

0

將在設備打開蘋果的地圖應用程式中

NSString *ll = [NSString stringWithFormat:@"%f,%f",latitude,longitude]; 
    ll = [ll stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 
    NSString *url = [NSString stringWithFormat:@"http://maps.apple.com/?q=%@", ll]; 
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]]; 
+0

我可以在uiwebview中打開此網址嗎? – Vidhi