Ios 对'的重新声明无效;mapView(ux0:viewFor:)&x27;
因此,我正在尝试创建一个在地图上带有自定义注释的应用程序,并且我一直在遵循一个关于如何做到这一点的教程。然而,当我把这个代码放进去时,它给了我一个错误 “mapView(\u0:viewFor:)”的重新声明无效 以下是教程-Ios 对'的重新声明无效;mapView(ux0:viewFor:)&x27;,ios,swift,xcode,Ios,Swift,Xcode,因此,我正在尝试创建一个在地图上带有自定义注释的应用程序,并且我一直在遵循一个关于如何做到这一点的教程。然而,当我把这个代码放进去时,它给了我一个错误 “mapView(\u0:viewFor:)”的重新声明无效 以下是教程- 当您已经在其他地方实现了该方法时,通常会发生这种情况 检查ViewController以确保没有func映射视图(\mapView:MKMapView,viewforannotation:MKAnnotation)->MKAnnotationView?{}在该扩展之外实现
当您已经在其他地方实现了该方法时,通常会发生这种情况
检查ViewController以确保没有
func映射视图(\mapView:MKMapView,viewforannotation:MKAnnotation)->MKAnnotationView?{}
在该扩展之外实现。当您已经在其他地方实现了该方法时,通常会发生这种情况
检查ViewController以确保没有func映射视图(\mapView:MKMapView,viewforannotation:MKAnnotation)->MKAnnotationView?{}
在该扩展之外实现
extension ViewController: MKMapViewDelegate {
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
guard let _annotation = annotation as? MyAnnotation else {return }
let identifier = "marker"
var view: MKMarkerAnnotationView
if let dequeuedView = mapView.dequeueReusableAnnotationView(withIdentifier: identifier) as? MKMarkerAnnotationView {
dequeuedView.annotation = annotation
view = dequeuedView
}
else
{
view = MKMarkerAnnotationView(annotation: annotation, reuseIdentifier: identifier)
view.canShowCallout = true
view.calloutOffset = CGPoint(x: -5, y: 5)
view.rightCalloutAccessoryView = UIButton(type: .detailDisclosure)
}
return view
}
}