Reputation: 366
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
if ([view.annotation isKindOfClass:MKUserLocation.class]) {
[mapView deselectAnnotation:view.annotation animated:YES];
}
else {
[mapView deselectAnnotation:view.annotation animated:YES];
view.image=[UIImage imageNamed:@"[email protected]"];//annotation pin
[self ToolTipView:view];//For adding the callout view
}
}
Upvotes: 1
Views: 118
Reputation: 5128
There is an open source project, SMCalloutView
, that solves this in a way similar to MapKit. Have a look here for the delegate protocol they've setup, which allows the delegate to adjust its content offset based on being close to screen edges:
https://github.com/nfarina/calloutview/blob/master/SMCalloutView.m#L303-L331
You could take a similar approach, though you'd have to do some MKMapPoint
translation from pixel values in order to control the MKMapView
offset similarly.
Upvotes: 1