无法使用skobbler选择注释

时间:2015-05-19 11:29:01

标签: swift dictionary ios8 annotations

我使用Skobbler SDK创建了一个地图并添加了一些注释,但是当我触摸一个注释时,以下方法将无法启动:

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)

1 个答案:

答案 0 :(得分:0)

我在创建地图时错过了行TU