0
我正在使用自定義MKAnnotationView
。我使用工作正常的autolayouts
,但註釋視圖的位置(框架)不合適。設置自定義MKAnnotationView的中心
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView)
{
if view.annotation is MKUserLocation
{
return
}
let starbucksAnnotation = view.annotation as! LiquorLocation
let views = Bundle.main.loadNibNamed("CustomCalloutView", owner: nil, options: nil)
let calloutView = views?[0] as! CustomCalloutView
calloutView.labelLiquorShopName.text = starbucksAnnotation.title
calloutView.labelLiquorShopAddress.text = starbucksAnnotation.address
calloutView.labelLiquorShopAwayDistance.text = starbucksAnnotation.locationKmAway
calloutView.imageViewLiquorShop.image = starbucksAnnotation.liquorShopIcon
calloutView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(calloutView)
mapView.setCenter((view.annotation?.coordinate)!, animated: true)
}
我做錯了嗎?我想將註釋視圖置於銷釘的頂部。