2013-02-15 46 views
0

我想在我的應用程序中使用iOS 6.1 SDK進行編譯時支持iOS5。從iOS SDK 6.1和目標iOS 5.0加載地圖應用程序

一個功能是將用戶帶到地圖應用程序。 Here is a link解釋如何使用適用於iOS 5的iOS SDK 5以及適用於iOS 6的iOS SDK 6執行此操作。

但是,如果我使用iOS 6.1 SDK並使用iOS 5設備,則magic URL link會將我帶到地圖。根據需要,在移動版Safari中使用google.com網站,而不是原生地圖應用。

這可以修復嗎?

編輯

到目前爲止,我有這樣的:

BOOL appleMapsSupported = FALSE; 
NSString *reqSysVer = @"6.0"; 
NSString *currSysVer = [[UIDevice currentDevice] systemVersion]; 
if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending) 
    appleMapsSupported = TRUE; 
if (appleMapsSupported){ 
    NSLog(@"device version %@", [[UIDevice currentDevice] systemVersion]); 
    MKPlacemark* placemark = [[MKPlacemark alloc] initWithCoordinate:coordinate addressDictionary:@{(NSString*)kABPersonAddressStreetKey:@"Your Place"}]; 
    MKMapItem* mapItem = [[MKMapItem alloc] initWithPlacemark:placemark]; 
    [mapItem openInMapsWithLaunchOptions:@{MKLaunchOptionsDirectionsModeKey : MKLaunchOptionsDirectionsModeWalking}]; 
}else{ 
    NSString* url = [NSString stringWithFormat:@"http://maps.google.com/?t=m&q=Your+Place%%40%g,%g", coordinate.latitude, coordinate.longitude]; 
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]]; 
} 

回答

2

蘋果已經更新了他們的URL處理地圖,你需要指向maps.apple.com,這將適當地重新定向到谷歌。 See the documentation for more/how

+0

剛剛在我的應用中用'maps.apple.com'替換'maps.google.com'並進行了測試,但同樣的問題仍然存在。 – ilmiacs 2013-02-15 17:47:53

+0

這可能是接着一個錯誤,底部(http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/LocationAwarenessPG/MapKit/MapKit.html#//apple_ref/doc/uid/TP40009497 -CH3-SW1)指出,對於iOS 5,您需要使用URL方案。這鏈接到我做的同一頁。 – WDUK 2013-02-15 18:15:04

+0

+1你指出我正確的方向。更詳細地閱讀規範,URL必須以'http://maps.apple.com/?q'開頭。 ('?q'很重要。)現在它起作用了。 :-) 謝謝! – ilmiacs 2013-02-15 18:20:05

0

鏈接的答案看起來不錯。所有你需要做的是檢查用戶正運行在iOS系統的版本,通過something like this,並執行相應的代碼爲iOS 6的情況下和iOS的低於6的情況。

+0

謝謝。這就是我現在正在做的。 – ilmiacs 2013-02-15 17:51:57