gpt4 book ai didi

ios - viewForAnnotation 不显示自定义图像 - iOS9

转载 作者:搜寻专家 更新时间:2023-11-01 07:29:31 27 4
gpt4 key购买 nike

我的 viewForAnnotation 在 iOS8 中运行良好,但在 iOS9 中不显示自定义图钉图像。图片路径没问题。
怎么了 ?谢谢!

func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
if annotation is MKUserLocation {
return nil //return nil so map view draws "blue dot" for standard user location
}

let reuseId = "pin"
var pinView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId)

if pinView == nil {
pinView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
pinView!.canShowCallout = true

}else{
pinView!.annotation = annotation
}
if annotation is MyAnnotation {
let myPin = annotation as! MyAnnotation

// Custom image in bubble
let viewLeftAccessory = UIView(frame: CGRectMake(0, 0, pinView!.frame.size.height + 20, pinView!.frame.size.height + 20))
let temp = UIImageView(frame: viewLeftAccessory.frame)
temp.image = UIImage(named: myPin.iconName)
viewLeftAccessory.addSubview(temp)
pinView!.leftCalloutAccessoryView = viewLeftAccessory

pinView!.image = UIImage(named: "BluePin")
pinView!.rightCalloutAccessoryView = UIButton(type: UIButtonType.DetailDisclosure) as UIView

return pinView
}
return nil
}

最佳答案

改变

pinView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: reuseId)

pinView = MKAnnotationView(annotation: annotation, reuseIdentifier: reuseId)

关于ios - viewForAnnotation 不显示自定义图像 - iOS9,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33536039/

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