检索iOS中特定国家/地区的国家/地区电话号码 [英] Retrieving a country telephone code for a specific country in iOS
问题描述
我对iOS开发很新,我正在构建我的第一个应用程序。
我正在尝试获取一个文本字段来自动填充特定国家/地区的电话国家/地区代码。
I'm quite new to iOS development and I'm currently building my first app. I'm trying to get a text field to automatically populate the telephone country code for a specific country.
因此,例如,如果用户选择UK他自动将+44插入该文本字段。
So if for example the user picks "UK" he gets "+44" inserted automatically into that text field.
目前我正在努力寻找如何获得该国家的确切国家电话代码。
我可以创建一个包含所有国家和国家电话代码的NSDictionary,但我认为可能有更好的方法。
Currently I'm struggling a way to find how to get the exact country telephone code for the country. I could create an NSDictionary with all of the countries and country telephone code but I thought there might be a better way.
推荐答案
如果您的目标是获取用户当前位置的拨号代码,那么您应该使用 HMDiallingCode 。
If your goal is to get the dialling code of the user's current location then you should use HMDiallingCode.
它使用CoreLocation和反向地理编码来获取用户的当前国家/地区,然后检索它的拨号代码。
It uses CoreLocation and reverse geocoding to get current country of the user and then retrieve it's dialling code.
这篇关于检索iOS中特定国家/地区的国家/地区电话号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!