在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
首先必须导入MapKit.framework库,并import <MapKit/MapKit.h> 这里是配合CLLocationManager(获取经纬度)使用,如果不知道CLLocationManager的用法,请参照我前面不远处的某篇博客有非常详细的记录了它的使用 func locationManager(manager: CLLocationManager!, didUpdateLocations locations: AnyObject[]!){ let thelocations:NSArray = locations as NSArray let location:CLLocation = thelocations.objectAtIndex(0) as CLLocation var geocoder:CLGeocoder = CLGeocoder() var placemarks:NSArray? var error:NSError? geocoder.reverseGeocodeLocation(location, completionHandler:{(placemarks,error) in if error == nil && placemarks.count > 0{ var placemark:CLPlacemark = (placemarks as NSArray).objectAtIndex(0) as CLPlacemark var detailAddress:String = "\(placemark.name)" var address:String = "\(placemark.locality)\(placemark.subLocality)\(placemark.thoroughfare)" } }) self.locationManager.stopUpdatingLocation() }
|
请发表评论