Xcode 错误消息:类型“[MKMapView]”的值没有成员“showsUserLocation”

Xcode 错误消息:类型“[MKMapView]”的值没有成员“showsUserLocation”,xcode,Xcode,我正在遵循Mapkit教程在地图上显示用户位置,但我得到类型为“[MKMapView]”的错误消息值?在使用代码mapView时没有成员“showsUserLocation”。showsUserLocation=true是否有解决此问题的方法 。。。 导入UIKit 导入地图套件 类ViewController:UIViewController{ private let locationManager = CLLocationManager() private var currentCoordi

我正在遵循Mapkit教程在地图上显示用户位置,但我得到类型为“[MKMapView]”的错误消息值?在使用代码mapView时没有成员“showsUserLocation”。showsUserLocation=true是否有解决此问题的方法

。。。 导入UIKit 导入地图套件

类ViewController:UIViewController{

private let locationManager = CLLocationManager()
private var currentCoordinate: CLLocationCoordinate2D?

@IBOutlet var mapView: [MKMapView]!
override func viewDidLoad() {
    super.viewDidLoad()
    configureLocationServices()
    // Do any additional setup after loading the view.
}

override func didReceiveMemoryWarning() {
   super.didReceiveMemoryWarning()
}

private func configureLocationServices () {
    locationManager.delegate = self
    let status = CLLocationManager.authorizationStatus()

    if status == .notDetermined {
        locationManager.requestAlwaysAuthorization()
    } else if status == .authorizedAlways || status == .authorizedWhenInUse {
        beginLocationUpdates(locationManager: locationManager)        }
}
   private func beginLocationUpdates(locationManager: CLLocationManager) {
    mapView.showsUserLocation = true
        locationManager.desiredAccuracy = kCLLocationAccuracyBest
        locationManager.startUpdatingLocation()
    }
private func zoomToLatestLocation(with coordinate: CLLocationCoordinate2D) {
    let zoomRegion = MKCoordinateRegion(center: coordinate, latitudinalMeters: 10000, longitudinalMeters: 10000)
     mapView.setRegion(zoomRegion, animated: true)
}
} 扩展视图控制器:CLLocationManagerDelegate{

func locationManager\uManager:CLLocationManager,didUpdateLocations位置:[CLLocation]{ 你有最新的位置吗

    guard let latestLocation = locations.first else { return }

    if currentCoordinate == nil {
        zoomToLatestLocation(with: latestLocation.coordinate)
    }
    currentCoordinate = latestLocation.coordinate  
}
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
    print("The status changed")
    if status == .authorizedAlways || status == .authorizedWhenInUse {
        beginLocationUpdates(locationManager: manager)
    }


无论如何,感谢您提供的帮助。我非常感谢。

请注意,您已将mapView声明为mkMapView数组。这就是方括号的意思:

@IBMOutlet var映射视图:[MKMapView]! 错误消息说是的,实际上,数组没有showsUserLocation方法

如果只需要一个mapView,则无需将其设置为数组:

@IBVAR映射视图:MKMapView!
非常感谢你的帮助!