创建的应用用到了Mapkit,好像只能在ios6中,所以想检测一下是不是Mapkit可用。代码如下:
if(NSClassFromString(@"MKMapKit")) {
// MKMapKit在此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";
//当前位置
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在此OS不可用
locationController = [[MyCLController alloc] init];
locationController.delegate = self;
[locationController.locationManager startUpdatingLocation];
}
但是不知道为什么它总是用Google的方法,请帮忙。谢谢