等到方法成功运行

时间:2014-06-08 05:12:08

标签: ios multithreading mapkit

我想确保[mapView addAnnotation: annotation1]已经运行并调用所有代理,然后运行其余的代码。

 -(void) addAnnotations:(double)latit :(double)longit :(NSString*)value{


    Annotation *annotation1=[[Annotation alloc]init];
    annotation1.coordinate = CLLocationCoordinate2DMake(latit,longit);
    annotation1.title=[NSString stringWithFormat:@"%@", secondIdArray];
    [mapView addAnnotation:annotation1];

    if([annotationArray count]==0)
    {
        annotationArray=[[NSMutableArray alloc]initWithObjects:annotation1,nil];
        valueArray=[[NSMutableArray alloc]initWithObjects:secondIdArray,nil];
    }
    else{
        [annotationArray addObject:annotation1];
        [valueArray addObject:secondIdArray];

    }

    for(int i=0;i<[annotationArray count];i++)
    {
        Annotation *a = ((Annotation*)[annotationArray objectAtIndex:i]);

        MKAnnotationView *av1=[mapView viewForAnnotation:((Annotation*)[annotationArray objectAtIndex:i])];
        pinColor=[self colorForAcceleration2:[[valueArray objectAtIndex:i]intValue]];
        a.title=[NSString stringWithFormat:@"Particule Level:%@",[valueArray objectAtIndex:i]];
        a.color=pinColor;
        av1.image=[ZSPinAnnotation pinAnnotationWithColor:a.color];
        av1.annotation=a;
    }
}

- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views
{
    //Here
    [self.mapView selectAnnotation:[[self.mapView annotations]objectAtIndex:0] animated:YES];
}

0 个答案:

没有答案