Compatibility
- 2.5.0 and master5.35.25.15.04.2
- 2.5.0 and masteriOSmacOS(Intel)macOS(ARM)LinuxtvOSwatchOS
A localized, searchable country picker view controller with optional calling codes for iOS 9+ written in Swift.
pod 'GCCountryPicker'
Add GCCountryPicker to your file's import statements.
import GCCountryPicker
Create an instance of GCCountryPickerViewController.
let countryPickerViewController = GCCountryPickerViewController(displayMode: .withoutCallingCodes)
Set the delegate, data source (optional), and navigation title.
countryPickerViewController.delegate = self
countryPickerViewController.dataSource = self
countryPickerViewController.navigationItem.title = "Countries"
Embed the country picker view controller in a navigation controller.
let navigationController = UINavigationController(rootViewController: countryPickerViewController)
Present the navigation controller.
self.present(navigationController, animated: true, completion: nil)
Implement GCCountryPickerDelegate.
func countryPickerDidCancel(_ countryPicker: GCCountryPickerViewController)
func countryPicker(_ countryPicker: GCCountryPickerViewController, didSelectCountry country: GCCountry)
Implement GCCountryPickerDataSource if necessary.
func countryCodes(for countryPicker: GCCountryPickerViewController) -> [String]
GCCountryPicker is available under the MIT license. See the LICENSE file for more info.