pod 'GCCountryPicker'
将 GCCountryPicker 添加到您的文件的 import 语句中。
import GCCountryPicker
创建一个 GCCountryPickerViewController 的实例。
let countryPickerViewController = GCCountryPickerViewController(displayMode: .withoutCallingCodes)
设置代理、数据源(可选)和导航标题。
countryPickerViewController.delegate = self
countryPickerViewController.dataSource = self
countryPickerViewController.navigationItem.title = "Countries"
将国家/地区选择器视图控制器嵌入到导航控制器中。
let navigationController = UINavigationController(rootViewController: countryPickerViewController)
呈现导航控制器。
self.present(navigationController, animated: true, completion: nil)
实现 GCCountryPickerDelegate。
func countryPickerDidCancel(_ countryPicker: GCCountryPickerViewController)
func countryPicker(_ countryPicker: GCCountryPickerViewController, didSelectCountry country: GCCountry)
如果需要,实现 GCCountryPickerDataSource。
func countryCodes(for countryPicker: GCCountryPickerViewController) -> [String]
GCCountryPicker 在 MIT 许可证下可用。 有关更多信息,请参阅 LICENSE 文件。