iphone - How do I load different custom pins or identifiers based off of their property values? -


I have objects that are & lt; MKAnnotation & gt; . I load this array in my annotations using the annotation:.

Method:

  - (MKAnnotationView *) mapView: (MKMapView *) mapView viewForAnnotation: (id & lt; MkAnnotation & gt;) Annotation  < / Pre> 

I have loaded each PIN using a custom image:

  annotation view. Image = [UIImage imageNamed: @ "purp_pin.png"];   

However, I do not want all the pins to be loaded with this image.

How do I do this

If you have a few custom properties in your object which corresponds to MKAnnotation , in a way you can image To set it, access it in viewForNnotation :

  MyAnnotationClass * myAnnot = (MyNnotationClass *) annotation; If (myAnnot.someProperty == 42) Annotation View.image = [UIImage imageNamed: @ "purp_pin.png"]; Other annotations View.image = [UIImage imageNamed: @ "default.png"];   

Make sure the annotation view is dequeued or created or not regardless of the image property is set.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -