Get info on a mapview selected annotation

后端 未结 3 792
猫巷女王i
猫巷女王i 2021-01-22 13:22

I have annotations on a mapview and a callout with a button on each. What I need to do is grab properties from this callout, ie. the title, but logging this line:



        
相关标签:
3条回答
  • 2021-01-22 13:43

    This is how

     for (id annotation in mapView.annotations) {NSLog([annotation title]);}
    
    0 讨论(0)
  • 2021-01-22 13:45

    Here is what I did in the annotationviewClick function:

    Hope this helps

    -(IBAction) annotationViewClick:(id) sender{
    
        [self.view addSubview:LoadingView];
        Annotation *ann = [myMap.selectedAnnotations objectAtIndex:([myMap.selectedAnnotations count]-1)];
    
    
        NSLog(@"Selected:%@", [ann tag]);
    
    }
    
    0 讨论(0)
  • 2021-01-22 13:46

    mapView.selectedAnnotations returns an array of anotations. You should access its items to get info.

    0 讨论(0)
提交回复
热议问题