iPhone: Remove annotation from MKMapView which is in another view
Posted
by Nic Hubbard
on Stack Overflow
See other posts from Stack Overflow
or by Nic Hubbard
Published on 2010-05-18T05:45:03Z
Indexed on
2010/05/18
5:50 UTC
Read the original article
Hit count: 406
I have two views. The first is a MKMapView with some annotations. Clicking a UIButton pushes a second view on the stack. This has a UITableView with a list of annotations which correspond to the map annotations. So, when you click the delete button, how can I call my MKMapView which is in another view, so that I can remove the annotation. My MKMapView is declared in my app delegate, as well as my current class. I am trying to use the following, but it is not working:
RideAppDelegate *appDelegate = (RideAppDelegate *)[[UIApplication sharedApplication] delegate];
Annotation *ano;
CLLocationCoordinate2D anoPoint;
anoPoint.latitude = [[eventToDelete valueForKey:@"latitude"] doubleValue];
anoPoint.longitude = [[eventToDelete valueForKey:@"longitude"] doubleValue];
ano = [[[Annotation alloc] init] autorelease];
ano.coordinate = anoPoint;
[appDelegate.ridesMap removeAnnotation: ano];
[appDelegate release];
I must be trying to access the MKMapView of my other view incorrectly?
© Stack Overflow or respective owner