ios - map view custom annotation view images not loading properly in device -
i using multiple annotation views different images in map view. images loading in simulator not in device.i not able figure out reason issue..following code
- (mkannotationview *)mapview:(mkmapview *)mapview viewforannotation:(id<mkannotation>)annotation { if ([annotation iskindofclass:[mkuserlocation class]]) return nil; static nsstring * const annotationidentifier = @"customannotation"; annotationview1 = [mapurcommview dequeuereusableannotationviewwithidentifier:annotationidentifier]; mkannotationview *annotationview2 = nil; if (annotationview1) { annotationview1.annotation = annotation; if(mapurcommview.userinteractionenabled) annotationview1.image = [uiimage imagenamed:@"mappindarkblue75@2x.png"];// map-pin-black.png else { //if(annotationview1.annotation == self.currentannotation|| annotation == self.previousannotation) nslog(@"in annotation view 1"); annotationview1.image = [uiimage imagenamed:@"mapdrawpoint@2x.png"];// bluedot.png } annotationview1.tag=111; return annotationview1; } else { annotationview2 = [[mkannotationview alloc] initwithannotation:annotation reuseidentifier:annotationidentifier]; annotationview2.image = [uiimage imagenamed:@"mappindarkblue75@2x.png"];// map-pin-black.png annotationview2.canshowcallout = yes; return annotationview2; } return nil; }
here drawing physical boundaries location in app...so annotation view 1 view drawing presently & annoation view 2 having annotations custom view images(all annotations having same images) drawn in past..custom annotaion images loading fine in simulator not in device
it's worked me using custom class annotation.. please refer this sample apple documentation.
1.) allocate mapannotation
mapannotation = [[mapannotation alloc]init];
2.) set coordinate lat , long
cllocationcoordinate2d coord = cllocationcoordinate2dmake([[nbcgpslocation sharedinstance].gpslatitude doublevalue], [[nbcgpslocation sharedinstance].gpslongitude doublevalue]); [mapannotation setcoordinate:coord]; [self.mapsdkview addannotation:mapannotation];
3.) delegate method call once go lat , long location
-(mkannotationview *)mapview:(mkmapview *)mapview viewforannotation:(id<mkannotation>)annotation { if ([annotation iskindofclass:[customannotation class]]) { if(!customannotationview) customannotationview = [[mkannotationview alloc]init]; customannotationview.image = [uiimage imagenamed:@"locationcustom"]; customannotationview.annotation = annotation; return customannotationview; } else { if(!annotationview) annotationview = [[mkannotationview alloc]init]; annotationview.image = [uiimage imagenamed:@"locationicon"]; annotationview.annotation = annotation; return annotationview; } }
Comments
Post a Comment