So I have a MKMapView with all my pins added, and the colour of the pin is dependent on whether a value is set for that pin. When I first load the app, viewForAnnotation is called and the colours are set accordingly. However, when I update the pin's details (such as location, title, etc...) I also update the pinColour to find it doesn't update. It looks like viewForAnnotation isn't called again after the initial add.
I have read many questions similar to this and I can confirm that mapView.delegate = self;
Here is my viewForAnnotation code:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(MapAnnotation *)annotation
{
if([annotation class] == MKUserLocation.class)
return nil;
NSString *pinIdentifier = annotation.identifier; // This is a unique string for each pin and is getting populated every time!
MKPinAnnotationView *annotationView = (MKPinAnnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier:pinIdentifier];
if(annotationView == nil)
annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:pinIdentifier];
else
annotationView.annotation = annotation; // Never had this line fire...
annotationView.canShowCallout = YES;
annotationView.animatesDrop = NO;
annotationView.enabled = YES;
annotationView.tag = annotation.counter;
if(annotation.pinColour == Stopped) // from enum
annotationView.pinColor = MKPinAnnotationColorRed;
else
annotationView.pinColor = MKPinAnnotationColorGreen;
UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[infoButton addTarget:self action:#selector(mapCalloutButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
infoButton.tag = annotation.counter;
annotationView.rightCalloutAccessoryView = infoButton;
return annotationView;
}
Here is the code where I add the pin:
CLLocationCoordinate2D annotationCoord;
annotationCoord.latitude = latestPosition.latitude;
annotationCoord.longitude = latestPosition.longitude;
MapAnnotation *annotation = [[MapAnnotation alloc] init];
annotation.coordinate = annotationCoord;
annotation.identifier = theIdentifier;
annotation.title = theTitle;
annotation.subtitle = theSubtitle
annotation.pinColour = [self getPinColour];
annotation.counter = theCounter;
[theMapView addAnnotation:annotation];
Here is the code where I update the pin (different method to add):
updatePin = true;
pinCounter = mapPin.counter;
CLLocationCoordinate2D annotationCoord;
annotationCoord.latitude = latestPosition.latitude;
annotationCoord.longitude = latestPosition.longitude;
[mapPin setCoordinate:annotationCoord];
mapPin.identifier = theIdentifier;
mapPin.subtitle = theSubtitle;
mapPin.pinColour = [self getPinColour];
I'm not sure what I'm missing. viewForAnnotation is obviously working, it's just not ever called after the initial add! If it were to call this function I'm 100% sure it would work as it does the colour change if I restart the app!
EDIT: Oh and I really don't want to start removing annotations and re-adding them. It's what I'm doing in the short term anyway!
Actually, I dont' know if this worked for you but this is how I did it.
I didn't need to delete the annotation from map. All I need to do is tell the map to give me the annotation view for a parameter annotation. The map will return the correct annotation. From there, I have a property for my custom annotation to identify whether it is an active item, if yes, show the normal pin image, else show full pin image.
-(void)updateAnnotationImage:(CustomAnnotation *)paramAnnotation
{
MKAnnotationView *av = [geoMap viewForAnnotation:paramAnnotation];
if (paramAnnotation.active)
{
av.image = [UIImage imageNamed:#"PinNormal.png"];
}
else
{
av.image = [UIImage imageNamed:#"PinFull.png"];
}
}
Bit late but hopefully it helps others who came across this problem.
Due to the way the map view caches its annotations, you NEED to remove and re-add the annotation if you need to make changes to its appearance. A simple remove & add is the way to go. There is no cache invalidating mechanism but this.
I also found this answer helpful: In which case that mapView:viewForAnnotation: will be called?
Whenever you call addAnnotation method
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id < MKAnnotation >)annotation gets called.
Swift 2.1:
I had the same issue, and found a quick solution, trigger this when needed, also sending it to the main thread would be wise:
var annotationsArray = mapView.annotations
mapView.removeAnnotations(mapView.annotations)
mapView.addAnnotations(arrayIncs)
arrayIncs.removeAll()
Just spent a couple of hours to get this to work on Xamarin; this is a warning for other Xamarin developers. Make sure you use the ViewForAnnotation method and not the GetViewForAnnotation delegate. I was using the wrong method which returned new annotation views instead of the existing ones... of course it wasn't working!
Related
I am working on an application with an mkmapview, which drops pins onto a mapview.
I need to be able to colour the pins based on information about the pin.
The current code that drops the map pins is:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id)annotation {
if (annotation == self.mapView.userLocation) return nil;
NSLog(#"annotation = %#", annotation);
static NSString* AnnotationIdentifier = #"AnnotationIdentifier";
MKPinAnnotationView* customPin = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier];
customPin.pinColor = MKPinAnnotationColorRed;
customPin.animatesDrop = YES;
customPin.canShowCallout = YES;
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
customPin.rightCalloutAccessoryView = rightButton;
return customPin;
}
If I change the line:
customPin.pinColor = MKPinAnnotationColorRed;
Then I can change the colour of ALL the dropped pins, but how can I identify which pin is being dropped, so that I can only re-colour the pin if needed?
I added the log line:
NSLog(#"annotation = %#", annotation);
But it returns, for example:
annotation = <MapAnnotation: 0x7feabd749190>
annotation = <MapAnnotation: 0x7feac04edf50>
annotation = <MapAnnotation: 0x7feabd79f860>
How can I use this to identify the pin?
Or should I be colouring the annotation pins in a different location?
You can add any object that conforms to the MKAnnotation protocol to a map as an annotation.
I suggest creating a custom annotation object that has extra properties (like an enum for the pin type, for example)
Then in your viewForAnnotation method, once you make sure it's not the user location annotation, cast the id pointer to your custom annotation object type and check your custom properties to see what type of pin to display (it could be as simple as a switch statement.)
I am trying to make a map, where I can see my current location, and see what the street is called.
so far, I am able to put a pin on my map, but for some reason, I am not getting the callout.
and I have put a NSLog in my viewForAnnotation method, but it is not being called, so i wasn't able to test it.
can someone help me?
-(void)lat:(float)lat lon:(float)lon
{
CLLocationCoordinate2D location;
location.latitude = lat;
location.longitude = lon;
NSLog(#"Latitude: %f, Longitude: %f",location.latitude, location.longitude);
//One location is obtained.. just zoom to that location
MKCoordinateRegion region;
region.center=location;
//Set Zoom level using Span
MKCoordinateSpan span;
span.latitudeDelta=.005f;
span.longitudeDelta=.005f;
region.span=span;
[map setRegion:region animated:TRUE];
//MKReverseGeocoder *geocoder=[[MKReverseGeocoder alloc] initWithCoordinate:location];
//geocoder.delegate=self;
//[geocoder start];
if (cPlacemark != nil) {
[map removeAnnotation:cPlacemark];
}
cPlacemark=[[CustomPlacemark alloc] initWithCoordinate:location];
cPlacemark.title = mPlacemark.thoroughfare;
cPlacemark.subtitle = mPlacemark.locality;
[map addAnnotation:cPlacemark];
[cPlacemark release];
[mLocationManager stopUpdatingLocation];
}
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
// try to dequeue an existing pin view first
if ([annotation isKindOfClass:[CustomPlacemark class]]){
MKPinAnnotationView *pinView=(MKPinAnnotationView *)[map dequeueReusableAnnotationViewWithIdentifier:#"customIdentifier"];
if (!pinView)
{
// if an existing pin view was not available, create one
MKPinAnnotationView* cPinAnnoView = [[[MKPinAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:#"customIdentifier"] autorelease];
cPinAnnoView.pinColor = MKPinAnnotationColorPurple;
cPinAnnoView.animatesDrop = YES;
cPinAnnoView.canShowCallout = YES;
// Add button
UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[leftButton addTarget:self action:#selector(annotationViewClick:) forControlEvents:UIControlEventTouchUpInside];
cPinAnnoView.leftCalloutAccessoryView = leftButton;
} else
{
pinView.annotation = annotation;
}
return pinView;
}
return nil;
}
Right now I have customized my viewForAnnotation to be like this.
But I still can't get a callout from my pin and the pin remains red.
But it should be purple of nothing at all
I had the same problem which was not setting the MapView delegate to the File Owner.
Open your nib
Right click on the MapView
Drag the delegate to the File's Owner
I had the same problem, as you mentioned. The delegate had been set to ViewController, but the viewForAnnotation selector was not being called. After some checks, I realized if you do not call addAnotation in the main thread, mapView would not call viewForAnnotation, so following update resolved my problem:
Before:
[_mMapView addAnnotation:marker];
After:
dispatch_async(dispatch_get_main_queue(), ^{
[_mMapView addAnnotation:marker];
});
In order to get the viewForAnnotation to be called, add mapView.delegate=self; to e.g. the viewDidLoad method:
- (void)viewDidLoad {
[super viewDidLoad];
mapView.delegate=self;
}
Could it be that your annotation has been added outside the current view area of the MKMapView?
For storyboard, Ctl drag the MKMapView to the orange circle on the bottom bar of ViewController, and select delegate.
This will solve the problem.
As vatrif mentioned in the comments, you must set your delegate BEFORE adding annotations to your MKMapView object.
Others have already explained, odds are high you have not connected your mapview delegate to your controller. Its the first thing to check
i have been working in ios 9 Mapview related app and I experienced the same problem.
somehow I solved my problem, in my case im resizing the mapview.
I added delegate after i resize the mapview. it works now perfectly.!
After having set the delegate for the mapview if still the viewforannotation not getting called then this is something which you have missed - set the self.mapView.showsUserLocation to YES, in interface builder you can tick the shows userLocation option in attributes inspector.
I want to display different colour pins in a UIMapView based on the relative time they represent
but it seems the mapView:viewForAnnotation: method only does it's thing independent of when its called.
In my code example I have already retrieved earlier & newer locations from a file to self.fileArray .
the array holds objects called findings that has (among others) an age property .
newest findings start life as age #"0", and each time the array is reloaded ready to take new findings
they progress in age to #"1" and #"2" respectively after which they are then dropped.
Once they take on their new age property they are sent to the mapView:viewForAnnotation: method
to be displayed according to their new status as I iterate through the fileArray
the actual question is after the jump. A lot of interesting other-answers cropped up while formulating the question but none quite applied to my case
.
.
int size = [self.fileArray count];
for (int idx=(size-1); idx>0; idx--) // process backwards
{
annotationFlag = 0; // using a global just for now
self.finding = self.fileArray[idx];
if ([self.finding.age isEqualToString:#"2"]) {
[self.fileArray removeObjectAtIndex:idx];
}
if ([self.finding.age isEqualToString:#"1"]) {
self.finding.age = #"2";
[self.fileArray replaceObjectAtIndex:idx withObject:self.finding];
annotationFlag = 2;
// tried here , only displays the newest
}
if ([self.finding.age isEqualToString:#"0"]) {
self.finding.age = #"1";
[self.fileArray replaceObjectAtIndex:idx withObject:self.finding];
annotationFlag = 1;
// tried here, still only displays the same newest
}
} // end if
//<Breakpoint with Log here>
MKPointAnnotation* annotation = [[MKPointAnnotation alloc] init];
CLLocationCoordinate2D myCoordinate;
myCoordinate.latitude =[self.finding.myLat doubleValue];
myCoordinate.longitude=[self.finding.myLong doubleValue];
annotation.coordinate = myCoordinate;
[self.mapView addAnnotation:annotation];
} // end for
.
.
the annotation methods are fairly standard, as used by most everybody:
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation: (MKUserLocation *)userLocation {
_mapView.centerCoordinate = userLocation.location.coordinate;
}
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id)annotation {
if([annotation isKindOfClass:[MKUserLocation class]])
return nil;
static NSString *identifier = #"myAnnotation";
MKPinAnnotationView * annotationView = (MKPinAnnotationView*)[ self.mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
if (!annotationView)
{
annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
//<Breakpoint with Log here>
switch (annotationFlag) {
case 1:
annotationView.pinColor = MKPinAnnotationColorGreen;
break;
case 2:
annotationView.pinColor = MKPinAnnotationColorRed;
break;
default:
annotationView.pinColor = MKPinAnnotationColorPurple;
break;
}
annotationView.animatesDrop = YES;
annotationView.canShowCallout = NO;
}else {
annotationView.annotation = annotation;
}
annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeSystem]; // UIButtonTypeDetailDisclosure
return annotationView;
}
also under test is my neighbours dogs curiosity. the pins should show different colours for each foray
If I NSLog annotationFlag to console at various points mapView:viewForAnnotation: seems to be
ignoring the values in annotationFlag and only using the state last set, leading me to believe it is only acting when
the for loop is entirely finished, and not following iterations.
so the question is, why isn't the [self.mapView addAnnotation:annotation] call acting immediately. Ive put it within the for loop, and there is no doubling up happening there.
LATE EDIT:
using a combination of breakpoints and log-to-consoles as shown in the listings above, and commenting out the age increase processing results in an array of 42 elements ( including the old ones ready to be discarded ) and therefore 42 pins to be dropped.
When the mapView:viewForAnnotation method is reached I then have to step through for another 42 times and on the 43rd all the pins drop at once. Watching carefully its the same colour so I can verify the last colour used doesn't draw over any earlier ones. If that clarifies the problem.
There is no guarantee that the viewForAnnotation will be called immediately after addAnnotation or that it will be called only once.
The annotation could be added in a region that isn't currently visible or the user might pan or zoom the map which causes the annotation to come back into view. The map view will simply call it whenever or as often as it needs to.
This is by-design and simply how the delegate method approach works.
For this reason, your implementation of the delegate method should generally only use the annotation parameter passed to the method as the basis for all the logic inside the method. It should not rely on any external variables or make broad assumptions about when it will be called.
For other answers that may explain this in more detail, see:
Map view annotations with different pin colors
MKMapview annotation dynamic pin image changes after zooming
Map annotation display all the same image/pins for all points
Setting Map Pin colour dynamically for iOS, etc
For your question specifically, I suggest the following:
Right now you're adding annotations of type MKPointAnnotation which don't contain the "age" information that the viewForAnnotation method needs (I'm assuming this is what it needs).
Instead of using MKPointAnnotation, make your Finding class (or whatever the type is of the self.finding object) implement the MKAnnotation protocol itself. You should be able to find several examples of custom annotation classes on SO.
Then, instead of keeping an annotationFlag variable and creating MKPointAnnotation objects, add the Finding objects themselves (which contain their "age") directly to the map when calling addAnnotation.
In viewForAnnotation, set the pinColor after the if-else that creates/dequeues the view and just before the return. Be sure to set the pinColor based on the age property of the annotation object passed into the method (which will be a Finding type object). For example:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id)annotation
{
if([annotation isKindOfClass:[MKUserLocation class]])
return nil;
static NSString *identifier = #"myAnnotation";
MKPinAnnotationView * annotationView = (MKPinAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
if (!annotationView)
{
annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
annotationView.animatesDrop = YES;
annotationView.canShowCallout = NO;
annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeSystem];
}else {
annotationView.annotation = annotation;
}
//update the pinColor in the view whether it's a new OR dequeued view...
if ([annotation isKindOfClass:[Finding class]])
{
Finding *f = (Finding *)annotation;
if ([f.age isEqualToString:#"2"]) {
annotationView.pinColor = MKPinAnnotationColorGreen;
}
else if ([f.age isEqualToString:#"1"]) {
annotationView.pinColor = MKPinAnnotationColorPurple;
}
else {
annotationView.pinColor = MKPinAnnotationColorRed;
}
}
return annotationView;
}
i'll try to keep this very simple :
I'm very new to Objective-C (or programming actually) so i'll probably need an explanation more than just an answer.
What i'm trying to do and can't do (yet):
Getting a pin's coordinate after tapping it's disclosure, and eventually pass it through a segue.
Practically, i'm clicking my "info" icon on a pin I just created, and i'd like to see it's info in another page (a webview). This page would show coordinates (and other stuff that we don't need here).
Why :
Practically, i'm clicking my "info" icon on a pin's annotation created earlier by the user, and i'd like to see it's info in another page (a webview). This page would show coordinates (and other stuff that we don't need here).
My pins coordinates are stored into a
CLLocationCoordinate2D location;
I can't re-use the variables i used before because they might be outdated (it would only work if the user asks for the last one created...)
And I do not know how i can get a pin's coordinates ; there must be a method or something but i jsut can't find it. I've found MANY answers on the internet, and none seemed to work, probably because i didn't understand them properly. Anyway, i couldn't use them.
I'll show you bits of my code, it's pretty straight forward i guess :
There is the viewDidLoad, you probably want to see it, i guess :
- (void)viewDidLoad
{
[super viewDidLoad];
name = [[NSString alloc]init];
detail = [[NSString alloc]init];
UILongPressGestureRecognizer *lpgr = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:#selector(longpressToGetLocation:)];
lpgr.minimumPressDuration = 2.0; //user must press for 2 seconds
[_map addGestureRecognizer:lpgr];
CLLocationCoordinate2D loc = CLLocationCoordinate2DMake(50.837863, 4.353616);
MKCoordinateSpan span = MKCoordinateSpanMake(.035, .035);
MKCoordinateRegion reg = MKCoordinateRegionMake(loc, span);
self.map.region = reg;
[self buildBaseAnno];
self.map.showsUserLocation = true;
}
I know this is important but to be honest i don't fully understand how this bit works ; still, it does work. :D
-(MKAnnotationView*)mapView:(MKMapView*)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
MKAnnotationView* v = nil;
{
static NSString* ident = #"Pin";
v = [_map dequeueReusableAnnotationViewWithIdentifier:ident];
if (v == nil)
{
v = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:ident];
((MKPinAnnotationView*)v).pinColor = MKPinAnnotationColorRed;
UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
v.rightCalloutAccessoryView = infoButton;
v.centerOffset= CGPointMake(0,-20);
v.canShowCallout= YES;
}
v.annotation = annotation;
}
return v;
}
Touch pin creation :
- (void)longpressToGetLocation:(UIGestureRecognizer *)gestureRecognizer
{
if (gestureRecognizer.state != UIGestureRecognizerStateBegan)
return;
CGPoint touchPoint = [gestureRecognizer locationInView:self.map];
location = [self.map convertPoint:touchPoint toCoordinateFromView:self.map];
[self showAlertName];
}
The actual annotation/pin creation method
-(void)buildAnno
{
CLLocationCoordinate2D coordinate;
coordinate.latitude = location.latitude;
coordinate.longitude = location.longitude;
MKPointAnnotation* newann = [MKPointAnnotation new];
newann.coordinate = coordinate;
newann.title = name;
newann.subtitle = detail;
[self.map addAnnotation:newann];
}
Please, do tell if you need more of the code ; i'm not really sure what i can give you, as my code is probably 'correct' (or decent), i just need to actually know how to get the information i need (that is, coordinates and other stuff from the pin i just tapped.)
And i actually don't tap the pin, i tap the disclosure in the pin's annotation. Anyway, That's enough for now !
Once i can catch these coordinates, i believe i'll be able to pass them through the segue as passing Data is already well explained here, but if there is anything 'special', i'd be really glad if you could add it to your explanation because i'm still really uncomfortable with all this and most of the tutorials/guides/links i've found didn't really help me.
Thank you very much for your time and help :)
(Edit : I had found a similar question here but i believe i need extra help/explanation.)
You don't need the gesture recogniser - the map view delegate protocol already has a method that tells you when the callout accessory was tapped calloutAccessoryControlTapped and this method receives the relevant annotationView. The annotationView.annotation property gets you back to the relevant annotation object and then you can access its coordinate property to get the coordinates of the pin.
First, create a new property in your class:
#property CLLocationCoordinate2D tappedCoord;
then implement the delegate method
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
MKPointAnnotation *annotation=(MKPointAnnotation*)view.annotation;
self.tappedcoord=annotation.coordinate;
[self performSegueWithIdentifier:#"detailViewSegue"]; // Use your appropriate segue identifier
}
Then you can access the property in prepareForSegue (again, change to the appropriate segue name and destination view controller class)
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:#"detailViewSegue" ]){
DetailViewController *dvc=(DetailViewController *)segue.destinationViewController;
dvc.coord=self.tappedCoord;
}
Also, since your MapView is displaying the user's location, there will be an annotation for that. You need to address this in your viewForAnnotation method, returning nil if the annotation isn't one of yours. You can check the class of the annotation to determine this -
-(MKAnnotationView*)mapView:(MKMapView*)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
MKAnnotationView* v = nil;
if ([annotation isMemberOfClass:[MKPointAnnotation class]]) {
static NSString* ident = #"Pin";
v = [_map dequeueReusableAnnotationViewWithIdentifier:ident];
if (v == nil)
{
v = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:ident];
((MKPinAnnotationView*)v).pinColor = MKPinAnnotationColorRed;
UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
v.rightCalloutAccessoryView = infoButton;
v.centerOffset= CGPointMake(0,-20);
v.canShowCallout= YES;
}
v.annotation = annotation;
}
return v;
}
I am using the MKMapView object and I am able to create pins and place them on the map. What I am trying to do now is get the information back from the pin. For example in my
- (MKAnnotationView*) mapView:(MKMapView *)mapView viewForAnnotation (id<MKAnnotation>)annotation
I create my pins and set them on the map. I am also creating buttons to use when a user clicks on the pin. All that works well and good. Now my question is when that button is clicked how do I get information from that clicked pin? Below is a small sample code of how I currently have it setup. Any advice would be greatly appreciated.
- (MKAnnotationView*) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
MKPinAnnotationView *annView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:#"location"];
annView.pinColor = MKPinAnnotationColorRed;
annView.animatesDrop = YES;
annView.canShowCallout = YES;
annView.calloutOffset = CGPointMake(-5, 5);
UIButton* callout = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[callout addTarget:self action:#selector(loadDetails:) forControlEvents:UIControlEventTouchUpInside];
annView.rightCalloutAccessoryView = callout;
return annView;
}
- (void)loadDetails:(id)sender
{
//TODO: Get pin coordinates or address and match it back to an array of available address to show details in a new view
}
Any advice is greatly appreciated
Instead of setting the target of your callout, respond to the delegate method
mapView:annotationView:calloutAccessoryControlTapped:
The annotationView will have an annotation property with the coordinate.
You should create a class that derives from MKPinAnnotationView that has a property of id<MkAnnotationView>. During the method above, create this new object instead of the MKPinAnnotationView and set the id<MKAnnotation> property to the annotation passed in.