Custom annotation view not working on iOS6

I am using the J4n0 callout code ( github ) to implement custom annotation in MapKit.

It worked great on iOS5. But on iOS6 I have 2 problems:

  • Annotations are displayed above the AnnotationView (see Figure 1).
  • The first click on the annotation opens the AnnotationView just fine, but the second click opens the annotation with a poor size (see Figure 2).

Anyone using this library have a similar problem / solution?

I can provide the code if necessary!

annotation on the viewbad size

+2
source share
2 answers

If annotations appear in AnnotationView, try entering the code:

- (void)didMoveToSuperview { [super didMoveToSuperview]; [self.superview bringSubviewToFront:self]; } 

Just in case the solution above does not work, try

 view.layer.zposition = 1 
+2
source

I'm not sure if you used the same code as mine, I loaded it from somewhere in the user annotationView , and I also realized that the second time the size is wrong. I noticed that the removeAnnotation function removeAnnotation also make the annotationView call its didMoveToSuperview again! Then I dug up the codes in didMoveToSuperview and found that the codes that I downloaded (hope you will find the same thing) do the animation so that it does the animation codes twice. This creates the problem that β€œa second click opens a poorly sized annotation”

Therefore, delete these animation codes or call it elsewhere and NOT in didMoveToSuperview , but correctly. Hope this helps you and hope you share your advice if you find out I'm wrong.

-1
source

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


All Articles