ios - Customizing MKAnnotationView only through subclassed MKMapView? -
i've tried both (mkmapview delegate):
-(void) mapview:(mkmapview *)mapview didaddannotationviews:(nsarray *)views { (mkannotationview *annotationview in views) { annotationview.image = [uiimage imagenamed:@"itemtype2.png"]; annotationview.rightcalloutaccessoryview = [uibutton buttonwithtype:uibuttontypedetaildisclosure]; annotationview.canshowcallout = yes; } } and (on vc has mkmapview):
[self.themapview addannotations:annotationsarray]; (id <mkannotation> itemannotation in self.themapview.annotations) { mkannotationview *itemannotationview = [self.themapview viewforannotation:itemannotation]; itemannotationview.image = [uiimage imagenamed:@"itemtype2.png"]; itemannotationview.rightcalloutaccessoryview = [uibutton buttonwithtype:uibuttontypedetaildisclosure]; itemannotationview.canshowcallout = yes; //[self.themapview setneedsdisplay]; } whithout success on changing mkannotationview's appearance, appear simple red pins without disclosure buttons or anything....
is way of changing them through creating subclassed mkmapview , using - (mkannotationview *)viewforannotation:(id < mkannotation >)annotation ??? feel it's desnecessary create subclass changing annotations, why don't above methods work?
you don't need subclass set properties on mkannotationview.
you need implement viewforannotation delegate method , set properties there.
see this answer code example.
the change example use mkannotationview instead of mkpinannotationview.
Comments
Post a Comment