MICountryPicker是一个支持搜索的iOS8+国家选择控制器,国家列表基于ISO 3166国家代码标准(http://en.wikipedia.org/wiki/ISO_3166-1)。此外,该库包括了从https://github.com/pradyumnad/Country-List获得的250个公有领域国旗图片。
MICountryPicker可以通过CocoaPods获取,要安装它,只需将以下行添加到Podfile即可
use_frameworks!
pod 'MICountryPicker'
从UIViewController显示MICountryPicker
let picker = MICountryPicker()
navigationController?.pushViewController(picker, animated: true)
// delegate
picker.delegate = self
// Optionally, set this to display the country calling codes after the names
picker.showCallingCodes = true
func countryPicker(picker: MICountryPicker, didSelectCountryWithName name: String, code: String) {
print(code)
}
func countryPicker(picker: MICountryPicker, didSelectCountryWithName name: String, code: String, dialCode: String) {
print(dialCode)
}
// or closure
picker.didSelectCountryClosure = { name, code in
print(code)
}
picker.didSelectCountryWithCallingCodeClosure = { name, code, dialCode in
print(dialCode)
}
Mustafa Ibrahim, [email protected]
适用于iOS 8+。
MICountryPicker在MIT许可证下可用。有关更多信息,请参阅LICENSE文件。