我正在构建一个使用 Mapkit 的应用程序。我知道这仅在IOS6中可用。所以我应该检查这是否可用。我正在使用以下代码。
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];
}
但出于某种原因,它总是使用 google 方法。
任何人都可以帮忙!