views:

588

answers:

3

I have a map annotation view that contains a rightcallout button which loads an accessory view which is a UIViewController class. I am using resuable annotations, but am wondering how I can pass updated information to my UIViewController class. Let's say I have 2 string values which map to 2 UILabels on my view. How can I update those values after the initial accessory view has already been loaded into memory as a resusable view?

Any help would be appreciated.

A: 

You'll need to maintain a reference to the UILabels in the object that gets the update, and then use setTitle: (I think) to update the labels.

lucius
A: 

In your annotation subclass you need to override the setTitle method to send the changes to the instance of your UIViewController class that your subclass is holding. Or, you could setup your annotation subclass to receive notifications (from NSNotificationCenter), and upon receiving a notification, update the title and the instance of your UIViewController class.

If you are unfamiliar with NSNotifications, then here is a quick reference. I used these to keep my annotations updated. NSNotification Example

benasher44
A: 

Try using the MKMapViewDelegate method:

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

This method is called when a user tapped one of the annotation view’s accessory buttons. Assuming that your MKMapViewDelegate is also the UIViewController that can access your accessory view.

Shiun