gpt4 book ai didi

iphone - 如何选择注释并将 id 传递到特定的详细信息页面?

转载 作者:行者123 更新时间:2023-12-03 21:05:41 24 4
gpt4 key购买 nike

我在 myannotation 类自定义中添加了 beepid 作为字符串,这是休息:

- (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 委托(delegate)方法而不是 didSelectAnnotationView 来检测选择。

在这两种情况下,您首先使用 view.annotation 访问注释对象,然后使用注释对象的某些属性(可能是自定义的)确定详细数据。

例如,如果您创建了自定义 MKAnnotation 类(而不是使用 MKPointAnnotation),则可以向其中添加 beepId 属性,在创建注释时设置它,并在委托(delegate)方法中您可以像这样检索它:

MyAnnotationClass *myAnnot = (MyAnnotationClass *)view.annotation;
objCont.mId = myAnnot.beepid;

关于iphone - 如何选择注释并将 id 传递到特定的详细信息页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7282337/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com