ios - MKAnnotation display all pin titles without clicking -
i adding multiple annotations programmatically this:
- (void)addannotations{ nsinteger i; cllocationcoordinate2d location; ( = 0 ; < [storelatitude count] ; ++ ){ location.latitude = [[storelatitude objectatindex:i] floatvalue]; location.longitude = [[storelongitude objectatindex:i] floatvalue]; mapviewannotation *newannotation = [[mapviewannotation alloc] initwithtitle:[listofstores objectatindex:i] andcoordinate:location]; [self.mapview addannotation:newannotation]; [newannotation release]; } } is possible display title pins without clicking on them?
declare array store annotation , use mkmapview's setselectedannotations:(nsarray *) method
- (void)addannotations { nsmutablearray *annotationarray = [[nsmutablearray alloc]init]; nsinteger i; cllocationcoordinate2d location; ( = 0 ; < [storelatitude count] ; ++ ) { location.latitude = [[storelatitude objectatindex:i] floatvalue]; location.longitude = [[storelongitude objectatindex:i] floatvalue]; mapviewannotation *newannotation = [[mapviewannotation alloc] initwithtitle: [listofstores objectatindex:i] andcoordinate:location]; [annotationarray addobject:newannotation]; [self.mapview addannotation:newannotation]; } [mapview setselectedannotations:annotationarray]; }
Comments
Post a Comment