我試圖抓住用戶位置的經度和緯度。我有一個代碼在棄用之前工作,我無法弄清楚如何解決它。座標棄用截至iOS 7
錯誤位於latestLocation.coordinate.latitude和latestLocation.coordinate.longitude的座標部分,錯誤狀態:'coordinate'不可用:從iOS 7及更早版本開始棄用的API在Swift中不可用。
謝謝你的幫助。
func locationManager(manager: CLLocationManager!,
didUpdateLocations locations: [AnyObject]!)
{
var latestLocation: AnyObject = locations[locations.count - 1]
latitude.text = String(format: "%.4f",
latestLocation.coordinate.latitude)
longitude.text = String(format: "%.4f",
latestLocation.coordinate.longitude)
if startLocation == nil {
startLocation = latestLocation as! CLLocation
}
}
',不贊成使用的iOS 7的API和更早版本中Swift.'似乎無法自我解釋,不是嗎?谷歌搜索'IOS 8 SWIFT獲取用戶位置'似乎產生了良好的效果 –