I tried to select my annotation programmatically. So in my custom map renderer i used this.
_iosMap.SelectAnnotation(myAnnotation, true);
myAnnotation got selected all right but right after that it got deselected. (Info window showed for a second than it vanished)I have no idea why. I mean when user tapped in certain regions my program adds annotation to map and right after that it calls SelectAnnotation to display the infowindow.
I tried to implement this solution.
void OnDidDeselectAnnotationView(object sender, MKAnnotationViewEventArgs e) {
MKMarkerAnnotationView annotationView = (MKMarkerAnnotationView) e.View;
if (someBoolToDetectUnwantedDeselect) {
_iosMap.SelectAnnotation(annotationView.Annotation, true);
}
}
But it did not work. I mean annotation got selected(OnDidSelectAnnotationView method fired.) But infowindow didn't appear. How can i solve this?
I tried to use GestureRecognizerShouldBegin(saw it here. ) But on select,deselect GestureRecognizerShouldBegin didn't fire.
Addition : I reproduces the issue here.
http://www.mediafire.com/file/s1ahsdum258yqpk/selectannotationproblem.rar/file
When tapped on map anywhere besides pin SelectAnnotation fires in CustomMapRenderer. Infowindow shows for a second than it vanishes.
When i added this to the OnDidDeselectAnnotationView
((MKMapView)Control).SelectAnnotation(((MKMapView)Control).Annotations.ElementAt(0), true);
In vanishes on the first tap just like before. And on second, third taps it works okay. Why first?