0

I have a set of annotations on my map, each of which have a right callout button. When that button is called it opens a pop up window, which I can create easily, but I cannot figure out how to populate it with traits such as the title within the popup. Here is my code I have

    - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:.2];
    [_infoview setAlpha:1];
    [UIView commitAnimations];
    _infoview.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.001, 0.001);
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDelay:0];
    [UIView setAnimationDuration:0.3/1.5];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(bounceInfoAnimation)];
    [self.view addSubview:_popView];
    _infoview.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.1, 1.1);
    [UIView commitAnimations];

    lblTitle.text = pawpost.title;
}

Now my question is how can I get the title to populate in the window. Do I need to try to do it all through this function? A different function? Or do I need to create a completely new file to write it in?

I am also trying to separately have a button that calls the phone number of that chosen location. This is the code I have but the "pawpost.phone" is not corresponding.

    -(IBAction)callPhone:(id)sender {

    NSString* yourActualNumber = [NSString stringWithFormat:@"tel:%@",pawpost.phone];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:yourActualNumber]];
    NSLog(@"phone");
}
user2792928
  • 147
  • 1
  • 1
  • 9
  • If you mean how to get access to the annotation that this method was called for, that would be through `view.annotation`. So the title would be `view.annotation.title`. –  Jan 09 '14 at 03:02
  • Thank you that did work for the title... One other question. I have a separate action that calls the phone number of the location too but I am having a hard time isolating the phone number for that one annotation clicked. I have edited my original post, if you have a suggestion for the second part too that would be much appreciated. – user2792928 Jan 09 '14 at 04:08
  • Is callPhone: called when a callout accessory button is pressed? Do your annotation objects have a phone property? See http://stackoverflow.com/questions/9797047/how-to-keep-data-associated-with-mkannotation-from-being-lost-after-a-callout-po/9797331#9797331. –  Jan 09 '14 at 11:55
  • Its not called directly it is a button within the view that animates in. So what I am curious about is should I create that view that appears in a completely separate view controller page that overlays on or can I do it all within the one view controller? – user2792928 Jan 09 '14 at 18:58
  • "it is a button within the view that animates in": That animates in from where? Is callPhone: in the same view controller that contains the map view? If so, the currently selected annotation is available through the `mapView.selectedAnnotations` array. See the linked question in previous comment. –  Jan 09 '14 at 19:26

0 Answers0