嘿我有一些座標[「37.7」,「-122.4」],我試圖用來反轉geoCode。所以我可以得到一個簡單的UI標籤的城市和國家。 但是,當我使用CLLocation通過用placeMark標準的administrativeArea var/method來獲取狀態時,它返回nil。ClLocation地標不返回管理區域
▿一些:1個元件 - 0:舊金山灣,舊金山灣,舊金山,美國@ < + 37.80000000,-122.50000000> +/-100.00米,區域CLCircularRegion(標識符:」 < + 37.79999999,-122.50000000>半徑141.72' ,中心:< + 37.79999999,-122.50000000>,半徑:141.72米)
這是我從完成處理回。這使得很明顯,沒有任何狀態從這個返回。爲什麼會這樣,我還能如何獲得這個狀態。
封閉的代碼塊控制這個行動所有幫助表示讚賞。
CLGeocoder().reverseGeocodeLocation(location, completionHandler: { (placeMark, error) in
if error != nil{
print("There was an error")
}else{
if let place = placeMark?[0]{
print(place)
print(place.locality ?? "")
print(place.subAdministrativeArea ?? "")
let myAttribute = [NSAttributedStringKey.font:UIFont(name: "Times New Roman", size: 15.3)!]
let myAttrString = NSAttributedString(string: place.locality ?? "", attributes: myAttribute)
locLabel.attributedText = myAttrString
}
}
})
如果您覺得數據庫中存在錯誤,則可能會對Apple提出錯誤。 – matt
是的,我剛剛意識到我身處水體 –