objective c - viewForAnnotation didn't get called (iOS noob) -


i know question has been asked others before , have read them in forum previously, have tried proposed approach without luck far decided post question.

i have piece of code below meant change pin icon on mkmapview. viewforannotation function doesn't seem called mkmapview. people said got problems delegating function file's owner can done dragging map view in .xib file file owner or defining mymap.delegate = self. have done both ways still nothing.

really appreciate problem, thanks.

code:

- (mkpinannotationview*)mymap:(mkmapview*)mymap viewforannotation:(id<mkannotation>)annotation{      mkpinannotationview *pin = [[mkpinannotationview alloc]initwithannotation:annotation reuseidentifier:@"custompin"];      uiimage *icon = [uiimage imagenamed:@"bustour.png"];     uiimageview *iconview = [[uiimageview alloc] initwithframe:cgrectmake(8,0,32,37)];      if(icon == nil)         nslog(@"image: ");     else         nslog(@"image: %@", (nsstring*)icon.description);      [iconview setimage:icon];     [pin addsubview:iconview];     pin.canshowcallout = yes;     pin.pincolor = mkpinannotationcolorpurple;      return pin; } 

delegation enter image description here

your delegate method named incorrectly mymap:viewforannotation:.

the viewforannotation delegate method must named mapview:viewforannotation: this:

- (mkannotationview *)mapview:(mkmapview *)mapview              viewforannotation:(id < mkannotation >)annotation {     //code goes here... } 

the map view exact method name.
if not found, won't call , create default red pin instead.


can change name of internal parameters not method name.

for example, ok:

- (mkannotationview *)mapview:(mkmapview *)mymap              viewforannotation:(id < mkannotation >)annotation {     //code goes here... } 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -