Show Current Location and Update Location in MKMapView in Swift

前端 未结 10 1454
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-02 12:06

I am learning how to use the new Swift language (only Swift, no Objective-C). To do it, I want to do a simple view with a map (MKMapView). I want to find and up

10条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-02 13:03

    In Swift 4, I had used the locationManager delegate function as defined above ..

    func locationManager(manager: CLLocationManager!, 
        didUpdateLocations locations: [AnyObject]!) {
    

    .. but this needed to be changed to ..

    func locationManager(_ manager: CLLocationManager,
        didUpdateLocations locations: [CLLocation]) {
    

    This came from .. https://github.com/lotfyahmed/MyLocation/blob/master/MyLocation/ViewController.swift - thanks!

提交回复
热议问题