Ranjan Sahu
Ranjan Sahu

Reputation: 300

how to remove pin from map after deleting pin at detail screen pop over to map view pin is still on map

i am doing map application .where i am showing annotation pin on map .On pin there is accessory button on click of pin accessory button it navigate to pin detail page.In detail page there is a delete button to delete place .after deleting while i am pop to map view the pin is showing on map .but my object array decremented by 1.But pins are showing as previous how to solve it .My requirement is ti aftre deleting when user pop to map view that pin will not show on map view.Please help me.....

Upvotes: 1

Views: 190

Answers (1)

Paras Joshi
Paras Joshi

Reputation: 20551

First try this method just call this method when you remove annotation..

-(void) reloadMap
{
    [yourMapView setRegion:yourMapView.region animated:TRUE];
}

Option

Else just remove all annotation and add again with your array object.. remove annotation like this

 MKCoordinateRegion region;
 MKCoordinateSpan span;
 span.latitudeDelta=0.04;
 span.longitudeDelta=0.04;

region.span=span;  
region.center = currentLocation; 
[MymapView removeAnnotations:[MymapView annotations]];
MyAnnotation *ann = [[MyAnnotation alloc] init]; ///This is My Annotation class which i create for display detail of location
ann.title =MymapView.userLocation.title;  
ann.subtitle = MymapView.userLocation.subtitle;
ann.coordinate = currentLocation;
ann.annLocation=[NSString stringWithFormat:@"%f%f",currentLocation.longitude,currentLocation.latitude];
[MymapView addAnnotation:ann];

[MymapView setRegion:region animated:TRUE];
[MymapView regionThatFits:region];

Upvotes: 0

Related Questions