Swift 2.0
iOS 8.0 +
CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like CityPicker in your projects. See the Get Started section for more details.
use_frameworks!
pod "CityPicker"
If you like to live on the bleeding edge, you can use the master
branch with:
pod 'CityPicker', :git => 'https://github.com/salvonos/CityPicker'
- Clone, add as a submodule or download
- Add all the files under
Classes
to your project. - Enjoy.
Copy the countriesToCities.json
file into the CityPicker Pods Bundle Resources.
-
Select Pods from the Project Navigator
-
Select Target CityPicker
-
Select tab
Build Phases
-
In
Copy Bundle Resources
import the json filecountriesToCities.json
from resorces folder
import CityPicker
CityPicker is designed to be extremely easy to use. First create an instance of class CityPickerViewController
, and then call it whenever you need it.
let cityPicker = CityPickerViewController()
@IBAction func showCityPicker(sender: AnyObject) {
self.cityPicker.showCityPicker(self, backgroundColor: UIColor.clearColor(), blurView_hidden: false)
}
The Delegate has 3 required functions. First add the CityPickerViewControllerDelegate
in your class and you are ready to receive the selected values in your own class.
func CityPickerDidSelectRow(nation: String, city: String) {
print("\(nation), \(city)")
}
func CityPickerDidPressedCancelButton() {
print("canceled")
}
func CityPickerDidPressedSelectButton(CityPicker: CityPickerViewController, nation: String, city: String) {
cityLabel.text = "\(city), \(nation)"
}
- Support OS X
- Convert UTF8 symbols in json List
- Add missing cities
- If you have some advice or you want to add a missing city open an issue or a PR.
- Email [Salvo Nostrato](mailto: info@salvonostrato.com?subject=CityPicker)
Salvo Nostrato, info@salvonostrato.com
CityPicker is available under the MIT license. See the LICENSE file for more info.