How to track where the appearance of the accessory on the right leader is when it has been activated

As you can see below, I have an annotation in which there is a right button. When the user enters the right button, I present a popover - the problem is that I don’t know where the user knocked, so I don’t have X and Y to display the popover accordingly.

How to find out where the user knocked, i.e. X and Y?

HotelAnnotationView *customPinView = [[HotelAnnotationView alloc] initWithAnnotation:theHotel reuseIdentifier:hotelPin];

//The right button which allows user to see hotel information
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
[rightButton addTarget:self action:@selector(showDetailsForHotel:) forControlEvents:UIControlEventTouchUpInside];

rightButton.tag = theHotel.id;
customPinView.rightCalloutAccessoryView = rightButton;
+3
source share
2 answers

Just implement

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control

which will be called in your delegate every time a user removes calloutAccessoryControl. Then you can access annotation properties through

view.annotation

, , (id), , lat , , , .

+6

showDetailsForHotel: sender, . , .

+1

Source: https://habr.com/ru/post/1776742/


All Articles