小编Ste*_*Lam的帖子

CLGeocodeCompletionHandler ios swift3

有没有人知道swift3上的任何变化?如何修复以下代码我使用geococdeAddressString

class func getMapByAddress(_ locationMap:MKMapView?, address:String?, title: String?, subtitle: String?)
{
            let geocoder = CLGeocoder()
            geocoder.geocodeAddressString(address!, completionHandler: {(placemarks: [CLPlacemark]?, error: NSError?) -> Void in
                if let validPlacemark = placemarks?[0]{
                    print(validPlacemark.location?.coordinate)

                    let span = MKCoordinateSpanMake(0.05, 0.05)
                    let region = MKCoordinateRegion(center: (validPlacemark.location?.coordinate)!, span: span)
                    locationMap?.setRegion(region, animated: true)

                    let annotation = MKPointAnnotation()
                    annotation.coordinate = (validPlacemark.location?.coordinate)!
                    annotation.title = title
                    annotation.subtitle = subtitle
                    locationMap?.addAnnotation(annotation)
                }

            } as! CLGeocodeCompletionHandler)
}
Run Code Online (Sandbox Code Playgroud)

这一行出错......只是在此行崩溃,as! CLGeocodeCompletionHandler) 没有显示错误<private>

clgeocoder swift3

0
推荐指数
1
解决办法
802
查看次数

标签 统计

clgeocoder ×1

swift3 ×1