Skip to content

Instantly share code, notes, and snippets.

@hsylife
Last active November 4, 2016 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hsylife/cfb75533c6d8106fe3bcc3c06b173d0c to your computer and use it in GitHub Desktop.
Save hsylife/cfb75533c6d8106fe3bcc3c06b173d0c to your computer and use it in GitHub Desktop.
PickerをPopoverで表示するライブラリの紹介 ref: http://qiita.com/hsylife/items/e54ae8bde0838db53ae3
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")}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment