banner

Release CocoaPods Documentation Codacy Code Quality Swift 4 Compatible Platform License

CocoaPods

pod 'GCCountryPicker'

实现

  1. 将 GCCountryPicker 添加到您的文件的 import 语句中。

    import GCCountryPicker
    
  2. 创建一个 GCCountryPickerViewController 的实例。

    let countryPickerViewController = GCCountryPickerViewController(displayMode: .withoutCallingCodes)
    
  3. 设置代理、数据源(可选)和导航标题。

    countryPickerViewController.delegate = self
    countryPickerViewController.dataSource = self
    countryPickerViewController.navigationItem.title = "Countries"
    
  4. 将国家/地区选择器视图控制器嵌入到导航控制器中。

    let navigationController = UINavigationController(rootViewController: countryPickerViewController)
    
  5. 呈现导航控制器。

    self.present(navigationController, animated: true, completion: nil)
    
  6. 实现 GCCountryPickerDelegate。

    func countryPickerDidCancel(_ countryPicker: GCCountryPickerViewController)
    
    func countryPicker(_ countryPicker: GCCountryPickerViewController, didSelectCountry country: GCCountry)
    
  7. 如果需要,实现 GCCountryPickerDataSource。

    func countryCodes(for countryPicker: GCCountryPickerViewController) -> [String]
    

文档

许可证

GCCountryPicker 在 MIT 许可证下可用。 有关更多信息,请参阅 LICENSE 文件。