objective c - MKPointAnnotation not working -


hello got method:

-(void)adressezeigen {     nslog(@"%s",__pretty_function__);      selectedannotation = [[mkpointannotation alloc]init];      selectedannotation.title = selectedcompanyname;     selectedannotation.subtitle = selectedcompanyadresse;     selectedannotation.coordinate = selectedcompanypoint;       nslog(@"selected title: %@",selectedannotation.title);     nslog(@"selected subtitle: %@",selectedannotation.subtitle);     nslog(@"selected latitude is: %f", self.selectedannotation.coordinate.latitude );     nslog(@"selected longitude is: %f", self.selectedannotation.coordinate.longitude );      [mapview addannotation:selectedannotation];      mkcoordinateregion selectedregion;      selectedregion.center = selectedcompanypoint;     selectedregion.span.longitudedelta = 0.01;     selectedregion.span.latitudedelta = 0.01;     [mapview setregion:selectedregion animated:yes];  } 

it should give me annotation in mapview.

my log output is:

-[secondviewcontroller adressezeigen] selected title: company 2 selected subtitle: company 2 adresse selected latitude is: 48.620000 selected longitude is: 9.460000 

but somehow dont annotation on map.

can please me?

this alone not gonna give actual annotation views on map. in order have annotation views in map, need declare mkmapviewdelegate view controller, declare mapview delegate , implement method:

-(mkannotationview *)mapview:(mkmapview *)mapview viewforannotation:(id<mkannotation>)annotation 

this method produces annotation view map view. in case might want use mkpinannotationview mkpointannotation!

you can check protocol reference here.

edit: example implementation of method (that assumes of mkpointannotations have same purpose) be:

-(mkannotationview *)mapview:(mkmapview *)mapview viewforannotation:(id<mkannotation>)annotation {     static nsstring *reuseid = @"myreuseid";     mkpinannotationview * view = (mkpinannotationview *)[mapview dequeuereusableannotationviewwithidentifier:reuseid];     if (!view) {         view = [[mkpinannotationview alloc] initwithannotation:annotation reuseidentifier:reuseid];         //custom setup of view, such         //view.canshowcallout = yes;     }     return view; } 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -