控制 MapKit 引脚注释点击选择



我正在尝试捕获 MapKit 引脚点击选择以对该位置的详细信息视图执行 segue,我在注释引脚中有一个属性:

#import <MapKit/MapKit.h>
@interface alrededorLocation : NSObject <MKAnnotation> {
    NSString *_name;
    NSString *_address;
    CLLocationCoordinate2D _coordinate;
    NSDictionary *additionalInfo;
}

但是我无法捕获引脚选择来执行 segue,我尝试在 - (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view 中控制它

但我没有成功获得选定的引脚参考。

非常感谢

如果有人偶然发现这个问题,答案是访问MKAnnotationViewannotation属性。对于此特定情况,有效的代码是:

AlrededorLocation *tempLocation = (AlderorLocation *)view.annotation;
[self performSegueWithIdentifier:@"detalle" sender:tempLocation];

最新更新