如何将地图视图中的图钉发送回调出视图?

发布于 2024-09-29 14:07:47 字数 325 浏览 1 评论 0原文

我正在实现基于 MAPKit 的应用程序,因为我遇到了引脚显示的问题。有时它们会出现在 callOut 视图的顶部。我使用以下代码将引脚发回:

- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views
 {
          for (MKAnnotationView* annotationView in views) 
         {

              [mapView sendSubviewToBack:annotationView];
         }
}

I am implementing MAPKit Based application, In that I had a problem with the pins display. Some times they are coming on top of the callOut view. I used the following code to send the pins back:

- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views
 {
          for (MKAnnotationView* annotationView in views) 
         {

              [mapView sendSubviewToBack:annotationView];
         }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我们的影子 2024-10-06 14:07:47

在 IOS 5 和 IOS 6 中,我尝试了这个,

引脚永远不会重叠 CalloutView 是可以的。
我使用自定义 calloutview ,在文件 Base calloutView 中添加以下内容:

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

In IOS 5 and IOS 6 , I try this and it's ok

the pin never overlap CalloutView.
I use custom calloutview , in file Base calloutView I add this :

- (void)didMoveToSuperview {
    [super didMoveToSuperview];
    [self.superview bringSubviewToFront:self];
}
花落人断肠 2024-10-06 14:07:47

不记得标注气泡是否是annotationView的子视图,如果是以下应该可以工作......
如果您正在为 iOS 4.0 及更高版本编码,则可以使用这些

- (void)mapView:(MKMapView *)mapView didDeselectAnnotationView:(MKAnnotationView *)annotView {
     [mapView sendSubviewToBack:annotView];
}

- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)annotView {  
     [mapView bringSubviewToFront:annotView];   
}

否则尝试在annotationView 内实现

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    CGPoint point = [touch locationInView:self];
    if ([self pointInside:point withEvent:event]) {
        UIView *mySuperview = self.superview;
        while (mySuperview && ![mySuperview isKindOfClass:[MKMapView class]]) {
            mySuperview = mySuperview.superview;
        }
        if (mySuperview) {
            [mySuperview bringSubviewToFront:self];
        }
    }
}

希望这会有所帮助

Can't remember if the callout bubble is a subview of the annotationView, if it is the following should work...
If you're coding for iOS 4.0 and above you can use these

- (void)mapView:(MKMapView *)mapView didDeselectAnnotationView:(MKAnnotationView *)annotView {
     [mapView sendSubviewToBack:annotView];
}

- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)annotView {  
     [mapView bringSubviewToFront:annotView];   
}

Otherwise try implementing inside the annotationView

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    CGPoint point = [touch locationInView:self];
    if ([self pointInside:point withEvent:event]) {
        UIView *mySuperview = self.superview;
        while (mySuperview && ![mySuperview isKindOfClass:[MKMapView class]]) {
            mySuperview = mySuperview.superview;
        }
        if (mySuperview) {
            [mySuperview bringSubviewToFront:self];
        }
    }
}

Hope this helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文