gpt4 book ai didi

swift - 无法使用 skobbler 选择注释

转载 作者:行者123 更新时间:2023-11-28 09:07:48 27 4
gpt4 key购买 nike

我已经使用 Skobbler SDK 创建了一张 map 并添加了一些注释,但是当我触摸一个注释时,以下方法不会启动:

func mapView(mapView:SKMapView!, didSelectAnnotation annotation:SKAnnotation!) {
println("test")
}

注解创建代码:

//create the label
var label = UILabel(frame: CGRectMake(0, 54, 122, 21))
label.textAlignment = NSTextAlignment.Center
label.textColor = UIColor.whiteColor()
label.backgroundColor = UIColor.blackColor().colorWithAlphaComponent(0.3)
label.text = title

//create our view for the image
let coloredView1 = UIImageView(frame: CGRectMake(7, 5.5, 122, 75))
coloredView1.addSubview(label)
coloredView1.image = img

//create our view for the background image
let coloredView2 = UIImageView(frame: CGRectMake(0.0, 0.0, 136, 110))
coloredView2.addSubview(coloredView1)
coloredView2.image = UIImage(named: "mapMarker")

//create our view for center the annotation
let coloredView3 = UIImageView(frame: CGRectMake(0.0, 0.0, 136, 200))
coloredView3.addSubview(coloredView2)
//create the SKAnnotationView
let view = SKAnnotationView(view: coloredView3, reuseIdentifier: String(identifierView))

//create the annotation
let viewAnnotation = SKAnnotation()
//set the custom view
viewAnnotation.annotationView = view
viewAnnotation.identifier = Int32(identifier)
viewAnnotation.annotationType = SKAnnotationType.Blue
viewAnnotation.location = CLLocationCoordinate2DMake(lat, long)

let animationSettings = SKAnimationSettings()
map.addAnnotation(viewAnnotation, withAnimationSettings: animationSettings)

最佳答案

我在创建 map 时错过了 self.map.delegate = self 行。

关于swift - 无法使用 skobbler 选择注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30324369/

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