我正在尝试使用 MKMap API 并集成数据库表 ID,以便我可以单击按钮详细信息披露将用户发送到另一个页面以获取更多信息。我一直在 Apple 网站上的 MKMapKit 上寻找一些属性或方法来帮助我解决这个问题,并且浏览了一些没有答案的教程。
我试图将 id 附加到字幕上下文中,以便我可以在 MKAnnotationView 中检索它,在其中我制作 MKPinAnnotationView 并将按钮添加到 rightCalloutAccessoryView。它出错并且不想工作。
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
MKPinAnnotationView *annView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"mkpin"];
annView.animatesDrop = YES;
annView.canShowCallout = YES;
UIButton *disclosureButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
annView.rightCalloutAccessoryView = disclosureButton;
return annView;
}
我将这种技术用于地图上的单个图钉,它似乎有效,但我不需要 id...
当我尝试获取注释的副标题时,它会杀死应用程序。我知道 (id) 注释是一个整数,但我不知道如何操作这些信息。我认为上面的这个函数是在我的代码之后调用的:
[mapView addAnnotations:markers]; //其中标记是标题数组,副标题又名id
任何帮助将不胜感激。