0
所以,我是新來的迅速和我從目前的緯度和長期向城市名稱和國家做出的轉換,它工作正常,這樣的:如何在CLLocationManager中強制默認語言爲英語?
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
{
if didFindLocation == false
{
didFindLocation = true
locationManager.stopUpdatingLocation()
userLocation = locations[0]
long = userLocation.coordinate.longitude;
lat = userLocation.coordinate.latitude;
print("\(lat),\(long)")
converLocationToCity()
}
}
func converLocationToCity()
{
let geoCoder = CLGeocoder()
userLocation = CLLocation(latitude: self.lat, longitude: self.long)
geoCoder.reverseGeocodeLocation(userLocation, completionHandler:
{
(placemarks, error) -> Void in
var placeMark: CLPlacemark!
placeMark = placemarks?[0]
if let city = placeMark.addressDictionary!["State"] as? String
{
self.city = city as String
} else
{
self.city = ""
}
if let country = placeMark.addressDictionary!["Country"] as? String
{
self.country = country as String
} else
{
self.country = ""
}
self.currentCity.name = ("\(self.city), \(self.country)" as String)
print("\(self.currentCity.name)")
self.fetchWeather.performCurrentWeatherFetch(forSelectedCity: self.currentCity.name)
DispatchQueue.main.async()
{
(self.superview as! UICollectionView).reloadData()
}
})
}
但是,當設備設置爲其他語言,俄語爲例如它會以俄文字符返回城市名稱和國家,但我需要它只能是英文,請有人提供一些想法或建議?謝謝!
http://stackoverflow.com/questions/25144508/reverse-geocoding-to-return-results-only-in-english –
毫米它似乎是我需要的,但它在Objective中,我是新編程和swift,所以我嘗試了40分鐘已經無法管理它... –