We are seeing a new problem on iOS11 with some of our MKAnnotationViews not showing. They are all working fine on iOS10. Some display fine on iOS11 others don't. When we print information about the non-diplaying MKAnnotationView in the debugger we see:-
<MyAnnotationView: 0x10ab2ffc0; frame = (68.0071 237.374; 253.07 70.253); hidden = YES; layer = <_MKAnnotationViewLayer: 0x1c0a27f20>>
However we cannot change the hidden attribute. e.g. [myAnnotationView setHidden:NO] has no effect.
In the Debug View Hierarchy we can see that myAnnotationView has been added to the map but is hidden ( disabled “Show only displayed views”).
We have found a workaround driven by a clue whilst debugging. If we breakpoint just before the MyAnnotationView is returned to MKMapKit in
- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation
and eyeball (Quick look) the view in the debugger just before it is returned to the MkMapView, it is visible in the preview pane and if we then dump (print the variable) the Hidden attribute has now mysteriously disappeared and on resuming the run the annotationView now displays on the map!
<MyAnnotationView: 0x10ab2ffc0; frame = (68.0071 237.374; 253.07 70.253); layer = <_MKAnnotationViewLayer: 0x1c0a27f20>>
So we mimicked this in code by drawing the myAnnotationView to a graphics context and getting the image from it.
CGContextRef ctx = UIGraphicsGetCurrentContext();
[self.layer renderInContext:ctx];
UIImage *retImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext()
and now myAnnotationView displays fine all the time. We would prefer a fix rather than a workaround. Anyone else experienced this and got a clue what is wrong?