CountriesViewController - A view controller that allow user to select a countries. It supports single or multiple selection
Usually during development i have a needed to select a country from list, this simple controller enable you to display a countries list, in a current locale language, and select them. Choose CountriesViewController for your next project, I'll be happy to give you a little help!
★★ Star our github repository to help us!, or ☕ pay me a coffee ★★
Created by Luca Becchetti
- iOS 9+
- swift 4.0
Here's a highlight of the main features you can find in CountriesViewController:
- Current Locale Translations Countries name are displayed using current locale
- Single or multiple. You can use selection as single selection or multiple selection
Do you like CountriesViewController
? I'm also working on several other opensource libraries.
Take a look here:
- InAppNotify - Manage in app notifications
- SwiftMultiSelect - Generic multi selection tableview
- SwiftMulticastProtocol - send message to multiple classes
CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like InAppNotify in your projects. You can install it with the following command:
$ gem install cocoapods
To integrate CountriesViewController into your Xcode project using CocoaPods, specify it in your Podfile
:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
target 'TargetName' do
use_frameworks!
pod 'CountriesViewController'
end
Then, run the following command:
$ pod install
First of all import library in your project
import CountriesViewController
The basic code to show a simple notification is:
//If you are in a UIViewController
let countriesViewController = CountriesViewController()
countriesViewController.delegate = self
CountriesViewController.Show(countriesViewController: countriesViewController, to: self)
You have to implement the CountriesViewControllerDelegate also:
extension YourViewController : CountriesViewControllerDelegate{
/// MARK: CountriesViewControllerDelegate
func countriesViewController(_ countriesViewController: CountriesViewController, didSelectCountries countries: [Country]){
countries.forEach { (co) in
print(co.name);
}
}
func countriesViewControllerDidCancel(_ countriesViewController: CountriesViewController) {
print("user did tap cancel")
}
func countriesViewController(_ countriesViewController: CountriesViewController, didSelectCountry country: Country) {
print(country.name+" selected")
}
func countriesViewController(_ countriesViewController: CountriesViewController, didUnselectCountry country: Country) {
print(country.name+" unselected")
}
}
you can customize this parameters during inizialization:
/// Create a controller
let countriesViewController = CountriesViewController()
/// Show major country (this countries are displayed in top of tableview, before each others)
countriesViewController.majorCountryLocaleIdentifiers = ["GB", "US", "IT", "DE", "RU", "BR", "IN"]
/// Set initial selected countries
countriesViewController.selectedCountries = Countries.countriesFromCountryCodes(["AL"])
/// Allow or disallow multiple selection
countriesViewController.allowMultipleSelection = true
/// Set delegate
countriesViewController.delegate = self
/// Show
CountriesViewController.Show(countriesViewController: countriesViewController, to: self)
- Frind - www.frind.it
I'm interested in making a list of all projects which use this library. Feel free to open an Issue on GitHub with the name and links of your project; we'll add it to this site.
CountriesViewController is owned and maintained by Luca Becchetti
As open source creation any help is welcome!
The code of this library is licensed under MIT License; you can use it in commercial products without any limitation.
The only requirement is to add a line in your Credits/About section with the text below:
Countries selection by CountriesViewController - http://www.lucabecchetti.com
Created by Becchetti Luca and licensed under MIT License.
I am a professional programmer with a background in software design and development, currently developing my qualitative skills on a startup company named "Frind " as Project Manager and ios senior software engineer.
I'm high skilled in Software Design (10+ years of experience), i have been worked since i was young as webmaster, and i'm a senior Php developer. In the last years i have been worked hard with mobile application programming, Swift for ios world, and Java for Android world.
I'm an expert mobile developer and architect with several years of experience of team managing, design and development on all the major mobile platforms: iOS, Android (3+ years of experience).
I'm also has broad experience on Web design and development both on client and server side and API /Networking design.
All my last works are hosted on AWS Amazon cloud, i'm able to configure a netowrk, with Unix servers. For my last works i configured apache2, ssl, ejabberd in cluster mode, Api servers with load balancer, and more.
I live in Assisi (Perugia), a small town in Italy, for any question, contact me