Popover with Picker by Swift 3 for iPhone/iPad, iOS9+.
- Popover with Picker which can be chosen from several types, appears on iPhone or iPad.
- Swift 3, iOS9+. UIPopoverController free.
- Callback
- Swift 3, Xcode 8. (If you want to use it on Swift 2.3, please check up SwiftyPickerPopover 1.3)
- iOS 9+
- CocoaPods 1.1.0.rc.2+ or Carthage 0.12.0+
MIT.
For Installing it on Swift 3 with CocoaPods, specify it in your 'Podfile'.
platform :ios, '9.0'
use_frameworks!
pod 'SwiftyPickerPopover'
If you want to use it on Swift 2.3, specify it.
pod 'SwiftyPickerPopover ~> '1.3.0'
Run 'pod install'.
For Installing with Carthage, add it to your Cartfile.
github "hsylife/SwiftyPickerPopover"
Run 'carthage update --platform iOS'.
On Xcode, import the module.
import SwiftyPickerPopover
DatePickerPopover appears.
DatePickerPopover.appearFrom(
originView: button,
baseViewController: self,
title: "DatePicker",
dateMode: .Date,
initialDate: NSDate(),
doneAction: { selectedDate in print("selectedDate \(selectedDate)")},
cancelAction: {print("cancel")}
)
StringPickerPopover appears.
StringPickerPopover.appearFrom(
originView: button,
baseViewController: self,
title: "StringPicker",
choices: ["value 1","value 2","value 3"],
initialRow:0,
doneAction: { selectedRow, selectedString in print("done row \(selectedRow) \(selectedString)")} ,
cancelAction: { print("cancel")}
)
ColumnStringPickerPopover which has variable multiple components, appers.
ColumnStringPickerPopover.appearFrom(
originView: button,
baseViewController: self, title: "Columns Strings",
choices: [["Breakfast", "Lunch", "Dinner"], ["Tacos", "Sushi", "Steak", "Waffles", "Burgers"]],
initialRow: [0,0],
columnPercent: [0.5, 0.5],
fontSize: 12.0,
doneAction: { selectedRows, selectedStrings in print("selected rows \(selectedRows) strings \(selectedStrings)")},
cancelAction: {print("cancel")}
)
CountdownPickerPopover which returns interval time, appears.
CountdownPickerPopover.appearFrom(
originView: sender,
baseViewController: self,
title: "CountdownPicker",
dateMode: .countDownTimer,
initialInterval: TimeInterval(),
doneAction: { timeInterval in print("timeInterval \(timeInterval)")},
cancelAction: {print("cancel")}
)
DatePickerPopover with clearAction
DatePickerPopover.appearFrom(originView: button,
baseViewController: self,
title: "Clearable DatePicker",
dateMode: .Date,
initialDate: NSDate(),
doneAction: { selectedDate in print("selectedDate \(selectedDate)")},
cancelAction: {print("cancel")},
clearAction: { print("clear")}
)
StringPickerPopover with displayStringFor
let displayStringFor:((String?)->String?)? = { string in
if let s = string {
switch(s){
case "value 1":
return "π"
case "value 2":
return "π"
case "value 3":
return "π"
default:
return s
}
}
return nil
}
StringPickerPopover.appearFrom(
originView: button,
baseViewController: self,
title: "StringPicker",
choices: ["value 1","value 2","value 3"],
displayStringFor: displayStringFor,
initialRow:0,
doneAction: { selectedRow, selectedString in print("done row \(selectedRow) \(selectedString)")},
cancelAction: { print("cancel")}
)
StringPickerPopover appears from CollectionView's cell.
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let theCell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath)
StringPickerPopover.appearFrom(
originView: theCell,
baseView: collectionView,
baseViewController: self,
title: "CollectionView",
choices: ["value 1","value 2","value 3"],
initialRow:0,
doneAction: { selectedRow, selectedString in print("done row \(selectedRow) \(selectedString)")},
cancelAction: { print("cancel")})
}
Ken Torimaru GitHub for CountdownPickerPopover and ColumnStringPickerPopover.
BalestraPatrick GitHub