gpt4 book ai didi

ios - 当我改变它的坐标时,自定义 MKAnnotation 消失

转载 作者:行者123 更新时间:2023-11-30 13:09:12 25 4
gpt4 key购买 nike

我不太清楚这个问题以前是否有人回答过,但我找不到它,所以我想我会发布一个问题。

我有一个自定义 MKAnnotation,如果我使用以下坐标,则显示效果非常好:“74.8044595495237 -21.7716836352598”

var currLat: Double! = 74.8044595495237
var currLong: Double! = -21.7716836352598
let egg: EggPin = EggPin(coordinate: CLLocationCoordinate2DMake(currLat, currLong), title: "Egg", subtitle: "This is an egg")

效果很好。自定义 MKAnnotation 显示在 map 上,一切都很好。但是,当我通过从 currLat 和 currLong 中减去 1.0 来更改 EggPin 的坐标时,如下所示:

var currLat: Double! = 74.8044595495237
var currLong: Double! = -21.7716836352598
let egg: EggPin = EggPin(coordinate: CLLocationCoordinate2DMake(currLat - 1.0, currLong - 1.0), title: "Egg", subtitle: "This is an egg")

MKAnnotation 消失。我是 MapKit 的新手,所以我觉得我一定缺少一些关于设置坐标的非常简单的东西。下面是我的 EggPin 类,如果有帮助的话:

import Foundation
import MapKit

class EggPin: NSObject, MKAnnotation {

var coordinate: CLLocationCoordinate2D
var title: String?
var subtitle: String?

init(coordinate: CLLocationCoordinate2D, title: String, subtitle: String) {
self.coordinate = coordinate
self.title = title
self.subtitle = subtitle

super.init()

}
}

最佳答案

问题是,当我从中减去 1.0 时,MKAnnoation 远远超出了屏幕,但减去 0.005 效果很好,正如引脚所示。

关于ios - 当我改变它的坐标时,自定义 MKAnnotation 消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38927243/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com