CountryCallingCodes 0.1.1

CountryCallingCodes 0.1.1

Enara L.Otaegui 维护。



  • 作者
  • Ar4n3

CountryCallingCodes

Build Status codecov pod license

从所选国家获取国际电话代码和 Emoji 国旗的简单方法。提供了 Objective-C 和 Swift 的示例。

安装

您可以下载此项目,或者通过 Cocoapods 进行安装

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'

target 'TargetName' do
pod 'CountryCallingCodes'
end

如何使用

Objective-C

获取设备位置默认数据(例如:旗帜=>🇪🇸,代码=> "+34")

[[CountryCallingCode sharedInstance] setDelegate:self];
NSString *buttonString = [NSString stringWithFormat:@"%@\t%@", [CountryCallingCode sharedInstance].flag, [CountryCallingCode sharedInstance].code];
[_countryButton setTitle:buttonString forState:UIControlStateNormal];

要选择另一个国家,请从 storyboard 参考資料执行 segue,并在您的委托中实现

#pragma mark - Delegate Methods

- (void)updateCountryData {
    NSString *buttonString = [NSString stringWithFormat:@"%@\t%@", [CountryCallingCode sharedInstance].flag, [CountryCallingCode sharedInstance].code];
    [_countryButton setTitle:buttonString forState:UIControlStateNormal];
}

Swift

获取设备位置默认数据(例如:旗帜=>🇪🇸,代码=> "+34")

CountryCallingCode.sharedInstance().delegate = self
let buttonString = String.init(format: "%@\t%@", CountryCallingCode.sharedInstance().flag, CountryCallingCode.sharedInstance().code)
countryButton.setTitle(buttonString, for: .normal)

要选择另一个国家,请从 storyboard 参考資料执行 segue,并在您的委托中实现

//MARK: Delegate methods
func updateCountryData() {
   let buttonString = String.init(format: "%@\t%@", CountryCallingCode.sharedInstance().flag, CountryCallingCode.sharedInstance().code)
   countryButton.setTitle(buttonString, for: .normal)
}