2012-03-21 39 views
4

我需要的用戶,如果他想打開Safari瀏覽器,或在地圖應用的地圖可供選擇,但問題是,閹我這樣做:使用Safari打開地圖或地圖

NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f&dirflg=d", location.coordinate.latitude, location.coordinate.longitude, destinationLatitude, destinationLongitude]; 
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]]; 

或相同搭配:

[NSString stringWithFormat:@"maps://maps.google.com/maps? 

他們都打開地圖(我猜是因爲Safari瀏覽器重定向到地圖)

有沒有辦法迫使Safari瀏覽器打開它?

+0

[Select the app that that load the map](http://stackoverflow.com/questions/9790038/select-the-app-that-will-load-the-map) – Caleb 2012-03-26 02:41:45

回答

1

我不認爲你可以強制Safari打開maps.google.com網址。 Apple's documentation表示,如果地圖不可用,Safari將打開它,但否則會將這些URL發送到地圖。甚至連Safari都不會將用戶發送到地圖,而是將UIApplication類發送給用戶。如果您指定https協議,您可以看到不同之處 - 這樣它將打開Safari,然後將您帶入地圖。

+0

這是什麼我想,謝謝你確認 – 2012-03-21 20:04:12

相關問題