ios - Wait until method run successfully -
i make sure [mapview addannotation: annotation1]
has been run , call delegates , run rest of code.
-(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]; }
Comments
Post a Comment