Jas_meet
Jas_meet

Reputation: 366

How to adjust my mapView dynamically when user taps on the annotation because it is hiding my callout view from the top

- (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

Answers (1)

incanus
incanus

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

Related Questions