如何选择注释并将ID传递给特定的详细信息页面?
问题描述:
我加beepid在myannotation类自定义字符串,这是休息:如何选择注释并将ID传递给特定的详细信息页面?
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
DLog(@"calloutAccessoryControlTapped");
/// detail page opening but beeid not passing
MyAnnotation *myAnnot = (MyAnnotation *)view.annotation;
BeepsDetail *objCont = [[BeepsDetail alloc] initWithNibName:@"BeepsDetail" bundle:nil];
objCont.mId = myAnnot.beepid;
objCont.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController: objCont animated: YES];
//[paramDic setValue:[mObject.mDic objectForKey:@"beepid"] forKey:@"beepid"];
[objCont release];
}
答
线
NSMutableDictionary *dic = [placeName objectAtIndex:MKAnnotationView.annotion];
给出了一个错误,因为MKAnnotationView
是的类,并没有annotation
方法在类。您将使用的是view.annotation
,因为view
是所选的MKAnnotationView
的实例。另外,annotion
拼写错误。
但是,这仍然不会工作,因为view.annotation
是注释对象,而不是placeName
数组中的整数索引。
你说你是“点击右箭头”这意味着标注中的正确的标注配件按钮(而不是注释本身)。在这种情况下,您应该使用calloutAccessoryControlTapped
委托方法而不是didSelectAnnotationView
来检测选择。
在这两种情况下,首先使用view.annotation
访问注释对象,然后使用注释对象的某些属性(可能是自定义)来确定详细数据。
例如,如果您创建一个自定义MKAnnotation
类(而不是使用MKPointAnnotation
),你可以在beepId
属性添加到它,创建注释时设置,并在委托方法你可以检索这样的:
MyAnnotationClass *myAnnot = (MyAnnotationClass *)view.annotation;
objCont.mId = myAnnot.beepid;
+0
我更新了我的代码上面 – IphoneBites
错误在NSMutableDictionary * dic = [placeName objectAtIndex:MKAnnotationView.annotion];为注释 – IphoneBites