我已经完成了Mapview的出口,并设置了自我委托。也符合MKMapViewDelegate协议
@IBOutlet weak var theMapView: MKMapView!
...
theMapView.delegate = self
let addAnotation = MKPointAnnotation()
addAnotation.coordinate = CLLocationCoordinate2D(latitude: xxx, longitude: yyyy)
theMapView.addAnnotation(addAnotation)我可能做错了什么?谢谢!
发布于 2022-07-14 14:21:07
我找到了解决办法。
结果显示,在CLLocationCoordinate2D(latitude: xxx, longitude: yyyy)中提供无效的经度和纬度值是造成这种情况的原因。
在尝试了一些来自google的lat和long的其他值之后,委托方法现在正在被调用。
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
..
}https://stackoverflow.com/questions/72970758
复制相似问题