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 メソッドを使用します。
誰でも助けてくれますか!