내 프로젝트 사용자는 현재 특정 도시에 있지 않는 한 다음보기로 이동할 수 없습니다.영어로 된 사용자 도시 가져 오기
fetchCountryAndCity(location: location) { country, city in
print("country:", country)
print("city:", city)
if city == "Riyadh" || city == "الرياض" || city == "리야드" || city == "Riyah" {
문제가 I가 이름을 확인할 수있다 : 그래서 여기에 사용자가 내가 좌표를 가지고 확인 내 현재 위치를 얻을 클릭하면 내가
func fetchCountryAndCity(location: CLLocation, completion: @escaping (String, String) ->()) {
CLGeocoder().reverseGeocodeLocation(location) { placemarks, error in
if let error = error {
print(error)
} else if let country = placemarks?.first?.country,
let city = placemarks?.first?.locality {
completion(country, city)
}
}
}
다음 좌표의 도시를 확인하는 방법입니다 도시 이름의 출력은 장치의 언어에 따라 다르기 때문에 (테스트 중 발견 한대로) 올바르지 않습니다. 모든 언어로 된 도시의 이름을 확인하는 다른 방법이 있습니까?
위치 정보를 사용하십시오. –
당신은 내게 더 많은 세부 사항을 줄 수 있습니다 :) – leo0019
이 게시물은 도움이 될 수도 있습니다 : https://stackoverflow.com/questions/25144508/reverse-geocoding-to-return-results-only-in-english – Ghean