Custom Annotation View do not work on iOS6

被刻印的时光 ゝ 提交于 2019-12-19 10:18:53

问题


I'm using the J4n0 Callout code (github) to implement a custom annotation in MapKit.

It was working just fine on iOS5. But on iOS6 I have 2 problems:

  1. Annotations are displayed over the AnnotationView (see picture 1).
  2. The first Click on an Annotation opens the AnnotationView just fine, but the second click opens an annotation with a bad size (see picture 2).

Does anyone using this library have some similar problem/solution?

I can give some code if needed!


回答1:


If annotations are displayed over the AnnotationView try to code:

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

Just in case above solution doesn't work try

view.layer.zposition = 1



回答2:


I am not sure whether you used the same code as mine, I downloaded it from somewhere to custom the annotationView and I also figured out that in the second time, the size is incorrect. I had noticed that the removeAnnotation function, will also make the annotationView call its didMoveToSuperview once again! Then I dug into the codes in didMoveToSuperview and found that the codes that I downloaded (i hope u meet the same one), do some animation in it so this will make the animation codes call twice. That makes the problem that "second click open an annotation with a bad size"

So remove this animation codes, or make it call somewhere else and NOT in didMoveToSuperview but properly. I hope this will help you, and hope you will share your advice if find out that I am wrong.



来源:https://stackoverflow.com/questions/12605249/custom-annotation-view-do-not-work-on-ios6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!