开发者

How to select an annotaion and pass an id to specific detail page?

开发者 https://www.devze.com 2023-04-01 19:21 出处:网络
I added beepid as string in myannotation class custom and this is rest : - (void)mapView:(MKMapView *)mapView ann开发者_如何转开发otationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(U

I added beepid as string in myannotation class custom and this is rest :

- (void)mapView:(MKMapView *)mapView ann开发者_如何转开发otationView:(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];


}


The line

NSMutableDictionary *dic = [placeName objectAtIndex:MKAnnotationView.annotion];

gives an error because MKAnnotationView is the class and there is no annotation method in the class. What you would use is view.annotation since view is the instance of the MKAnnotationView that was selected. Also, annotion is spelled wrong.

However, that still won't work because view.annotation is the annotation object and not the integer index into your placeName array.

You say you are "clicking on the right arrow" which implies the right callout accessory button in the callout (and not the annotation itself). In that case, you should be detecting the select using the calloutAccessoryControlTapped delegate method instead of didSelectAnnotationView.

In both cases, you would first get access to the annotation object using view.annotation and then using some property (possibly custom) of the annotation object, determine the detail data.

For example, if you have created a custom MKAnnotation class (instead of using MKPointAnnotation), you could add the beepId property to it, set it when creating the annotation and in the delegate method you could retrieve it like this:

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

精彩评论

暂无评论...
验证码 换一张
取 消