如何选择注释并将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]; 


} 
+0

错误在NSMutableDictionary * dic = [placeName objectAtIndex:MKAnnotationView.annotion];为注释 – IphoneBites

线

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