3
votes

I have a project in xCode 4.2 using storyboards. I'm using the mapkit framework. I'm trying to position a popover by the annotation the user selected with a segue.

Here's what I have.

if([view.annotation isKindOfClass:[ContentPoint class]]) {
    NSLog(@"I see this in my log");

    [self performSegueWithIdentifier:@"ViewAudioSegue" sender:mapView.selectedAnnotations];
}

This calls the correct segue, but because the segue has an anchor of mapview, the popover displays at the botton of the map and not beside the selected annotation. I've tried different senders (view, map, etc.) but I get the same result. Is there a way to programmatically set the anchor? This is the error I get without manually setting the anchor "* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UIStoryboardPopoverSegue must be presented from a bar button item or a view.'"

2

2 Answers

0
votes

I found my answer

MapKit deselect Annotation and popover does not animate

It's not using segues, but it allows me to eliminate all nib files in my project and just use storyboards.

0
votes

You could also create a hidden button that you anchor the popover segue to and position the button over the annotation when it is selected. Here is a similar solution using a tableview in a separate question that I answered https://stackoverflow.com/a/14514837/1712892. The primary difference being that you would have to calculate the position of the annotation on the screen and move the anchorButton there, then pass your custom annotation as the sender when you perform the segue. I am actually doing this in the same project. If I have time I will edit this with examples later tonight.