As you can see below I have an annotation view that has a right button. When the user taps the right button I am presenting a popover – the problem is I don’t know where the user tapped so I don’t have the X and Y to display the popover accordingly.
How do I find out where the user tapped i.e. the 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;
Simply implement
Which will get called on your delegate everytime a user taps the calloutAccessoryControl. You can then access you annotation properties through
The reason I like this approach better than using the (id)sender is that you actually get access to not only your annotation lat & long coordinates, but any data that is actually associated with it so you can use that in your pop over view.