PickerPopupDialog is a a popup iOS picker control written in Swift 4. It lets you input any type of data in the format [(Any, String)].
To run the example project, clone the repo, and run pod install
from the Example directory first.
PickerPopupDialog is available through CocoaPods.
CocoaPods is a dependency manager for Swift and Objective-C that simplifies the use of 3rd-party
libraries like PickerPopupDialog
in your projects.
First, add the following line to your Podfile:
pod "PickerPopupDialog"
Second, install PickerPopupDialog
into your project:
pod install
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
To integrate PickerPopupDialog
into your Xcode project using Carthage, specify it in your Cartfile
:
github "ribasal1/PickerPopupDialog"
Run carthage update
to build the framework and drag the built PickerPopupDialog.framework
(in Carthage/Build/iOS folder)
into your Xcode project (Linked Frameworks and Libraries in Targets
).
- Copy
PickerPopupDialog.swift
into your project - That's it
Import if you are using Cocoapods
import PickerPopupDialog
Set the data source, in viewDidLoad for example. It must be of type [(Any, String)]
let pickerView = PickerPopupDialog()
let myDataSource : [(Any, String)] = [(1, "First item"),(2, "Second item")]
pickerView.setDataSource(myDataSource)
Show the picker and use the selected value
pickerView.showDialog("My Title", doneButtonTitle: "Ok", cancelButtonTitle: "cancel") { (result) -> Void in
//do something with the selected value
//Value = result.0
//Text = result.1
//close window
self.dismiss(animated: true, completion: nil)
}
Alberto Ribas, github@linkmedia.ch
PickerPopupDialog is available under the MIT license. See the LICENSE file for more info.