TestsTested | ✓ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Jan 2017 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Wonder Bear.
PickerController, can make correlational pick. I love it.
If you prefer not to use either of the aforementioned dependency managers, you can integrate PickerController into your project manually.
Open the example project, build and run.
extension UIViewController {
public func showCorrelationPicker(title:String, correlationalJsonStr: String, selectedItems: [String], onDone: ClosureDone? = nil, onCancel: ClosureCancel? = nil) {
...
}
public func showCorrelationPicker(title:String, correlationalJsonStr: String, selectedIndices: [Int], onDone: ClosureDone? = nil, onCancel: ClosureCancel? = nil) {
...
}
public func showCorrelationPicker(title:String, correlationalJsonFile: String, selectedItems: [String], onDone: ClosureDone? = nil, onCancel: ClosureCancel? = nil) {
...
}
public func showCorrelationPicker(title:String, correlationalJsonFile: String, selectedIndices: [Int], onDone: ClosureDone? = nil, onCancel: ClosureCancel? = nil) {
...
}
public func showGroupPicker(title:String, groupData: [[String]], selectedItems: [String], onDone: ClosureDone? = nil, onCancel: ClosureCancel? = nil) {
...
}
public func showGroupPicker(title:String, groupData: [[String]], selectedIndices: [Int], onDone: ClosureDone? = nil, onCancel: ClosureCancel? = nil) {
...
}
public func showDatePicker(title: String, initialDate: Date, onDone: ClosureDateDone? = nil, onCancel: ClosureCancel? = nil) {
...
}
}
extension UIViewController {
public func showPicker_ChineseRegionalism(title: String, selectedItems: [String], onDone: ClosureDone? = nil, onCancel: ClosureCancel? = nil) {
...
}
}
func onClicked_button1() {
let data = [["1983", "1984", "1985"], ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"]]
showGroupPicker(title: "Hello", groupData: data, selectedItems: ["1984", "6月"], onDone: { [unowned self] (indices, items) in
self.labelIndices.text = "indices -- \(indices)"
self.labelItems.text = "items -- \(items)"
}, onCancel: {
self.labelIndices.text = "selected nothing"
self.labelItems.text = "selected nothing"
})
}
func onClicked_button2() {
showPicker_ChineseRegionalism(title: "城市", selectedItems: ["江苏", "无锡"], onDone: { [unowned self] (indices, items) in
self.labelIndices.text = "indices -- \(indices)"
self.labelItems.text = "items -- \(items)"
}, onCancel: {
self.labelIndices.text = "selected nothing"
self.labelItems.text = "selected nothing"
})
}
func onClicked_button3() {
showDatePicker(title: "时间", initialDate: Date(), onDone: { [unowned self] (date) in
self.labelIndices.text = ""
self.labelItems.text = "date -- \(date)"
}, onCancel: {
self.labelIndices.text = ""
self.labelItems.text = "selected nothing"
})
}
xiongxiong, [email protected]
PickerController is available under the MIT license. See the LICENSE file for more info.