views:

38

answers:

1

How can I display a DisclosureButton in the userLocation (the blue dot) callout like the Apple Maps app does?

Now I just can change its title and subtitle, but I hope to provide custom callout views. Therefore, if I click the blue dot, it can display a button besides only title and subtitle. In this way, when I click the button, it can guide me to another View. I returned MKAnnotationView in viewForAnnotation when annotation == self.mapView.userLocation. However, the callout can display updated title and subtitle, but cannot show the button I added.

I really need this function, and I desire any help and suggestion!

+1  A: 

For the annotationView, set

myAnnotationView.canShowCallout=YES;

then add up to two buttons with

myAnnotationView.leftCalloutAccessoryView=myLeftButton;

myAnnotationView.rightCalloutAccessoryView=myRightButton;

The buttons can be a normal button, a custom button, or one of the predefined types. Like this:

myAnnotationView.rightCalloutAccessoryView=[UIButton buttonWithType:UIButtonTypeDetailDisclosure];

Then add the calloutAccessoryControlTapped: method to handle taps.

Henrik Erlandsson
Thank you Henrik, Ive been looking for this solution for hours.
daidai