Search code examples
objective-cmkmapviewmkannotation

Switch between multiple MKAnnotations objective-C


I have a MKMapView in a "Contact Us" section of my app. At the top of the view I have a Segmented control, one for each of the offices locations in the UK.

I have put a Pin on each of the locations already, but want to know how to changed the centred Annotation based on which section is selected on the Segmented control.

I hope this makes sense, any help would be appreciated.

thanks

Sam


Solution

  • You can use the MKMapView methods

    - (void)setRegion:(MKCoordinateRegion)region animated:(BOOL)animated
    

    or

    - (void)setCenterCoordinate:(CLLocationCoordinate2D)coordinate animated:(BOOL)animated
    

    passing in the location coordinate of the MKAnnotation you want to move to.