Map Annotations in iOS 6 do not rotate when a user clicks a map

Would love the answer to this question https://devforums.apple.com/message/723468 . I can’t publish the data because it is approximately on iOS 6 and is confidential to Apple.

Please post your answers / comments on the Apple Dev forum and let me know here.

EDIT: from the official release of iOS6:

In my pre-ios6 code, I do this to rotate the map when the user’s location moves:

//this is in my MKMapViewDelegate -(void) rotateMap:(MKMapView *)mapViewTmp forLocation:(MKUserLocation *) userLocation { ... //calculate needed rotation ... [mapViewTmp setTransform:CGAffineTransformMakeRotation(lastRotation)]; //rotate the MKMapView for (id<MKAnnotation> annotation in mapViewTmp.annotations) { MKAnnotationView* annotationView =[mapViewTmp viewForAnnotation:annotation]; [annotationView setTransform:CGAffineTransformMakeRotation(-lastRotation)]; //counter rotate the Annotation Views [annotationView setNeedsDisplay]; //ios6 } } 

And it works great (1000 users).

However, in ios6 (I updated Xcode / sdk on 9/4/2012), annotations do not support this rotation (for example, if the card is enabled). They lean back into the unarmed state (which, since my card is rotated, means that they display text at an angle instead of horizontally).

The code temporarily rotates the annotations, so their text is displayed horizontally, but if the map is tinted (and it seems they are also other reasons), the annotations are turned into their non-rotatable state, and my annotation text appears at an angle relative to the rotational display.

What is the correct way to rotate MKAnnotationView so that it rotates in iOS6? What has changed in MKMapView that caused the change?

+6
source share
3 answers

The fix for this is to do the following in the viewForAnnotation method:

 // iOS6 BUG WORKAROUND !!!!!!! if (is6orMore) { [annotationView setTransform:CGAffineTransformMakeRotation(.001)]; //any small positive rotation } 

This was posted as a comment from me in the original question, and then sent to cristis as an answer (referring to my comment), but I am sending and accepting my own answer since it was he who came to it. Did that make sense?

+5
source

This was posted as a comment, I resubmit it as an answer so that anyone can see it easily (and spend less time trying to figure it out).

And the fix ===> in the viewForAnnotation method:

 // iOS6 BUG WORKAROUND !!!!!!! if (is6orMore) { [annotationView setTransform:CGAffineTransformMakeRotation(.001)]; } 
+2
source

I saw the same thing. Here's the fix:

Set YOUR conversion on the child of the MKAnnotationView, so in the pseudo-code:

 view.child.transform = CGAffineTransformMakeRotation(0.3); 

Let them control the presentation of the annotation and take control of your viewing subtree. Converts concatenation, and you inherit everything, whatever they do. Works for me on iOS 6.

+1
source

Source: https://habr.com/ru/post/924881/


All Articles