I’ve noticed that if I use MKMapView’s selectAnnotation:animated:, that it will scroll my map off screen if the MKAnnotation is not displayed in the current MKCoordinateRegion that my map is displaying.
Is there a trivial way to check if an annotation is currently on screen within the specified MKCoordinateRegion? I’d like to be able to select an annotation that’s only on screen and not something offscreen.
Use the
annotationsInMapRect:method in theMKMapViewclass. It returns aNSSetof all annotation objects that are visible in the given map rect. Use thecontainsObject:method ofNSSetto test if the annotation is present in that set of visible annotations.Also
visibleMapRectis same as the region but just a different form of representation. Take from the docs,