【问题标题】:how to remove pin from map after deleting pin at detail screen pop over to map view pin is still on map删除详细信息屏幕上的图钉后如何从地图中删除图钉弹出到地图视图图钉仍在地图上
【发布时间】:2012-11-29 20:11:02
【问题描述】:

我正在做地图应用程序。我在地图上显示注释图钉。在图钉上,点击图钉附件按钮有附件按钮,它导航到图钉详细信息页面。详细信息页面有一个删除按钮用于删除地点。当我弹出到地图视图时删除引脚显示在地图上。但是我的对象数组减少了 1。但是引脚显示为以前的如何解决它。我的要求是当用户弹出到地图视图时删除该引脚不会在地图视图上显示。请帮助我.....

【问题讨论】:

    标签: iphone objective-c mkannotation


    【解决方案1】:

    先试试这个方法,去掉注解的时候调用这个方法..

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

    选项

    否则只需删除所有注释并使用您的数组对象再次添加.. 像这样删除注释

     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];
    

    【讨论】:

    • @RanjanSahu 看到更新的代码.. 只需按照代码流并根据您的要求更改某些内容,这非常简单且有效的伙计......
    • @RanjanSahu 试试这个方法.. -(void) reloadMap { [yourMapView setRegion:yourMapView.region animated:TRUE]; }
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多