我需要从 map 套件中禁用默认标注 View ,我正在使用自定义标注 View ,现在当我单击图钉图标时它会获取两个 View 。
func mapView(mapView: MKMapView, didSelectAnnotationView view: MKAnnotationView){
let customView = (NSBundle.mainBundle().loadNibNamed("CustomCalloutView", owner: self, options: nil))[0] as! CustomCalloutView;
let button = UIButton(frame: CGRectMake(0, 0, 100, 50))
button.addTarget(self, action: Selector("buttonPressed:"), forControlEvents: .TouchUpInside)
button.userInteractionEnabled = true
button.backgroundColor = UIColor.greenColor()
customView.addSubview(button) // assuming you're in a view controller
self.view.addSubview(customView)
}
最佳答案
终于找到解决方案了。
只需注释掉 MKAnnotation 对象自定义类中的“标题”和“描述”即可。
关于swift - 如何禁用 Mapkit 中的默认标注 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37314534/