2 ooomiao oOOMIAO 于 2012.12.07 17:08 提问

问题关于检测Mapkit可用性

创建的应用用到了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的方法,请帮忙。谢谢

1个回答

wangyaninglm
wangyaninglm   Ds   Rxr 2015.01.13 14:54

http://www.iliunian.com/766.html
这个是否对你有帮助?

Csdn user default icon
上传中...
上传图片
插入图片