Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 地图视图注释平差_Iphone_Ios_Mapkit_Mkmapview_Mkannotationview - Fatal编程技术网

Iphone 地图视图注释平差

Iphone 地图视图注释平差,iphone,ios,mapkit,mkmapview,mkannotationview,Iphone,Ios,Mapkit,Mkmapview,Mkannotationview,大家好,当用户进入下面的代码时,我正试图更改注释的图像 - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { for (int i = 0; i < [_annotationArray count]; i++) { //MKAnn

大家好,当用户进入下面的代码时,我正试图更改注释的图像

- (void)locationManager:(CLLocationManager *)manager   didUpdateToLocation:(CLLocation *)newLocation  fromLocation:(CLLocation *)oldLocation
{
    for (int i = 0; i < [_annotationArray count]; i++)
    {
        //MKAnnotation xxx = [_annotationArray objectAtIndex:i];

        Shadows* shadowObj2 = [_shadowArray objectAtIndex:i];

        NSLog(@"%@",_shadowArray);

        CLLocationCoordinate2D location3;

        location3.latitude  =  [shadowObj2.position_x floatValue];
        location3.longitude =  [shadowObj2.position_y floatValue];

        CLLocation* locationold = [[CLLocation alloc] initWithLatitude:location3.latitude longitude:location3.longitude];

        CLLocationDistance kilometers = [newLocation distanceFromLocation:locationold];

        //temp = [kilometers intValue];

        if (kilometers > 50 && kilometers <100)
        {
            MKAnnotationView* newA = [[MKAnnotationView alloc] initWithAnnotation:[_annotationArray objectAtIndex:i] reuseIdentifier:@"annotation1"];
            newA.image = [UIImage imageNamed:@"shadowS.png"];
            newA.canShowCallout = YES;
        }

        [locationold release];
        //[shadowObj2 release];
    }

}
-(void)locationManager:(CLLocationManager*)manager didUpdateToLocation:(CLLocation*)newLocation fromLocation:(CLLocation*)oldLocation
{
对于(int i=0;i<[u注释数组计数];i++)
{
//MKAnnotation xxx=[\u annotationArray objectAtIndex:i];
Shadows*shadowObj2=[\u shadowArray objectAtIndex:i];
NSLog(@“%@”,_shadowArray);
CLLocationCoordination2d location3;
位置3.latitude=[shadowObj2.position_x floatValue];
location3.longitude=[shadowObj2.position_y floatValue];
CLLocation*locationold=[[CLLocation alloc]initWithLatitude:location3.纬度经度:location3.经度];
CLLocationDistance km=[newLocation distanceFromLocation:locationold];
//温度=[数值];

如果(km>50&&km,则可以按照教程进行自定义注释


我认为此代码与地图视图没有任何关系,您正在使用新图像分配一个新的MKAnnotationView实例。这不会更改地图上已有的实例。您需要做的是检查地图视图中的注释距离,然后更改其图像