CountryCallingCodes
从所选国家获取国际电话代码和 Emoji 国旗的简单方法。提供了 Objective-C 和 Swift 的示例。
安装
您可以下载此项目,或者通过 Cocoapods 进行安装
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
target 'TargetName' do
pod 'CountryCallingCodes'
end
如何使用
Objective-C
获取设备位置默认数据(例如:旗帜=>
[[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
获取设备位置默认数据(例如:旗帜=>
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)
}