I solved the issue adding an observer. The observer then does its thing and after that the callout shows up.
Something I had problems with is that I couldn't update the information in the callout bubble after the bubble is shown. The only way to do this is to create your own callout bubble (as I understand it), which is something I didn't feel like given that I have a deadline.
I fixed that by adding an extra UIView with an alpha on it and a text "Getting location data...". I just show up that view when pressing an location and when the observer is done, I hide the view again (off course by using an animation).
Hope my answer helped others.
Code:
[pin addObserver:self
forKeyPath:@"selected"
options:NSKeyValueObservingOptionNew
context:GMAP_ANNOTATION_SELECTED];
Some more code:
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context{
NSString *action = (NSString*)context;
MKAnnotationView *annotationView = [(MKAnnotationView*)object retain];
BikeAnnotation *bike = [[annotationView annotation] retain];
if([action isEqualToString:GMAP_ANNOTATION_SELECTED] && [[bike _stationType] intValue] != 5 && [[bike _stationType] intValue] != 6){
BOOL annotationAppeared = [[change valueForKey:@"new"] boolValue];
if (annotationAppeared) {
NSLog(@"Annotation selected");
else {
NSLog(@"annotation deselected");
}
}
}
And put this just after the @synthesize's:
NSString * const GMAP_ANNOTATION_SELECTED = @"gmapselected";