ios - 移动 map 时 MGLCalloutView 掉落 (Mapbox iOS)

标签 ios swift mapbox mapbox-marker

平台:iOS (Swift) Mapbox SDK版本:3.6

嗨,我有一个自定义 MGLCalloutView,当我点击 MGLAnnotationView 时,标注会按预期显示在注释上方,但如果我稍微移动 map ,标注会轻微移动并下降覆盖注释。当标注丢失时,当您移动 map 时,它确实会保持锚定在该点。

我已经实现了isAnchoredToAnnotation,我不确定这是一个错误还是我实现了错误。我注意到在文档中它说实现 setCentre,所以我在 presentCallout 中设置了中心

self.center = CGPoint(x: frameWidth / 2, y: frameHeight / 2)
self.isAnchoredToAnnotation = true

最佳答案

设法解决这个问题,当您平移 map 时,中心正在更新,覆盖 View 中心的 Get/Set 解决了该问题。

override var center: CGPoint {

    set {
            var newCenter = newValue
            newCenter.y = newCenter.y - bounds.midY
            super.center = newCenter
       }

    get {

        return super.center

    }

}

关于ios - 移动 map 时 MGLCalloutView 掉落 (Mapbox iOS),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45709548/

相关文章:

iphone - 如何向 UIView 添加对角线描边

ios - 如何通过 prepare for segue 将不同的 url 传递给下一个 VC?

ios - 将mapkit注释对象转换为mapbox注释对象

ios - Objective-c:UIStackView 的动态大小,取决于它的内容

ios - Xcode 中的 "No provisioning profiles found"

ios - 在IOS 10中从Swift WkWebView接口(interface)(类似于Android JS接口(interface))获取Javascript函数返回

ios - JTAppleCalendar - 如何停止单元格随机重复?

javascript - mapbox-gl:根据中心点、缩放级别和尺寸计算 map 边界

ios - MapBox 在 iOS 位置添加交互式注释/ View

ios - 我们可以在不使用 APNS 的情况下使用 QuickBlox 作为新用户加入/添加到私有(private)组来发送通知吗?