oOOMIAO 2012-12-07 09:08 采纳率: 10%
浏览 1941

问题关于检测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条回答 默认 最新

  • shiter 人工智能领域优质创作者 2015-01-13 06:54
    关注

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

    评论

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大