Swift Package Index

GCCountryPicker

https://github.com/graycampbell/GCCountryPicker.git

A localized, searchable country picker view controller with optional calling codes for iOS 9+ written in Swift.


Compatibility

  • 2.5.0 and master
    5.3
    5.2
    5.1
    5.0
    4.2
  • 2.5.0 and master
    iOS
    macOS(Intel)
    macOS(ARM)
    Linux
    tvOS
    watchOS

banner

Release CocoaPods Documentation Codacy Code Quality Swift 4 Compatible Platform License

CocoaPods

pod 'GCCountryPicker'

Implementation

  1. Add GCCountryPicker to your file's import statements.

    import GCCountryPicker
    
  2. Create an instance of GCCountryPickerViewController.

    let countryPickerViewController = GCCountryPickerViewController(displayMode: .withoutCallingCodes)
    
  3. Set the delegate, data source (optional), and navigation title.

    countryPickerViewController.delegate = self
    countryPickerViewController.dataSource = self
    countryPickerViewController.navigationItem.title = "Countries"
    
  4. Embed the country picker view controller in a navigation controller.

    let navigationController = UINavigationController(rootViewController: countryPickerViewController)
    
  5. Present the navigation controller.

    self.present(navigationController, animated: true, completion: nil)
    
  6. Implement GCCountryPickerDelegate.

    func countryPickerDidCancel(_ countryPicker: GCCountryPickerViewController)
    
    func countryPicker(_ countryPicker: GCCountryPickerViewController, didSelectCountry country: GCCountry)
    
  7. Implement GCCountryPickerDataSource if necessary.

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

Documentation

License

GCCountryPicker is available under the MIT license. See the LICENSE file for more info.