在iOS中获取设备位置(仅限国家/地区) [英] Get device location (only country) in iOS

查看:722
本文介绍了在iOS中获取设备位置(仅限国家/地区)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要获取iOS设备的国家/地区位置。

I need to get the country location of a iOS device.

我一直在尝试将CoreLocation与MKReverseGeocoder一起使用。然而,这似乎经常发生错误。我只需要这个国家,不需要街道等。

I've been trying to use CoreLocation with MKReverseGeocoder. However this seems to return erraneous quite frequently. And I only need the country, no need for streets and such.

如何以更稳定的方式完成?

How can this be done in a more stable way?

推荐答案

NSLocale 只是关于当前使用的区域设置的设置,并不代表您所在的实际国家/地区in。

NSLocale is just a setting about currently used regional settings, it doesn't mean the actual country you're in.

使用 CLLocationManager 获取当前位置& CLGeocoder 执行反向地理编码。你可以从那里获得国家名称。

Use CLLocationManager to get current location & CLGeocoder to perform reverse-geocoding. You can get country name from there.

这篇关于在iOS中获取设备位置(仅限国家/地区)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆