我正在構建一個使用Mapkit的應用程序。我知道這隻在IOS6中可用。 所以我應該檢查這是否可用。我正在使用下面的代碼。如何檢查Mapkit是否可用?
if(NSClassFromString(@"MKMapKit")) {
// MKMapKit is available in this OS
CLLocationCoordinate2D coords =
CLLocationCoordinate2DMake(51.097185,5.621653);
NSDictionary *address = @{
(NSString *)kABPersonAddressStreetKey: @"Weg naar oqdffds 59",
(NSString *)kABPersonAddressCityKey: @"Msfsf",
(NSString *)kABPersonAddressStateKey: @"Limbusqfqsdf",
(NSString *)kABPersonAddressZIPKey: @"3670",
(NSString *)kABPersonAddressCountryCodeKey: @"BE",
(NSString *)kABPersonPhoneMainLabel:@"04741234567"
};
MKPlacemark *place = [[MKPlacemark alloc]
initWithCoordinate:coords addressDictionary:address];
MKMapItem *mapItem = [[MKMapItem alloc]initWithPlacemark:place];
mapItem.phoneNumber = @"0141343252";
//current location
MKMapItem *mapItem2 = [MKMapItem mapItemForCurrentLocation];
NSArray *mapItems = @[mapItem, mapItem2];
NSDictionary *options = @{
MKLaunchOptionsDirectionsModeKey:MKLaunchOptionsDirectionsModeDriving,
MKLaunchOptionsMapTypeKey:
[NSNumber numberWithInteger:MKMapTypeStandard],
MKLaunchOptionsShowsTrafficKey:@YES
};
[MKMapItem openMapsWithItems:mapItems launchOptions:options];
}else {
NSLog(@"tot hier");
// MKMapKit is not available in this OS
locationController = [[MyCLController alloc] init];
locationController.delegate = self;
[locationController.locationManager startUpdatingLocation];
}
但由於某種原因,它始終使用谷歌方法。
任何人都可以幫忙!
謝謝˚F或你的答案!這工作! – Steaphann