I have annotations on a mapView, and the callout button on the annotation view pushes another view called PinViewController onto the stack. I have a button on PinViewController that I want to remove the pin when it is pressed. I am not sure how to do this, can someone help me out?
Share
When you initialize the PinViewController you could pass it a variable that can later be used to identify the annotation. Maybe they have unique IDs or names. Pass it through and when the button is pressed you tell your previous view controller to remove that annotation. You could have a connection to your previous vc by making it a delegate or a weak reference (to avoid a reference loop). When the previous vc is given the ID it must go through all the annotations until it finds the one that matches the ID, and then tell the map view to remove that annotation. Hope that helps.