I have a pickerView linked with a button when you click to the Button it will appears ..
my problem is : I don't know how to get the result and print it to the textFiled I created..
if I can make the result in the button name without needed to the text filed will be great !!
thats what I did so far :
import UIKit
import ActionSheetPicker_3_0
class ViewController2: UIViewController {
@IBOutlet weak var text1: UITextField!
@IBAction func ssss(_ sender: Any) {
ActionSheetMultipleStringPicker.show(withTitle: "Multiple String Picker", rows: [
["One", "Two", "A lot"],
], initialSelection: [1],
doneBlock: {
picker, indexes, values in
self.text1.text = ("\(values)")
/**
print("values = \(values)")
print("indexes = \(indexes)")
print("picker = \(picker)")
return
**/
},
cancel: { ActionMultipleStringCancelBlock in return }, origin: sender)
}
I think you made a mistake with the variable name in the doneBlock
while you are assigning the value to the text field. Also, check out the initialSelection
parameter. You have provided [1]
which will select the whole Array.
ActionSheetMultipleStringPicker.show(
withTitle: "Multiple String Picker",
rows: [["One", "Two", "A lot"]],
initialSelection: [1, 1],
doneBlock: { picker, indexes, values in
// self.text1.text = ("\(vslues)")
// should be
self.text1.text = ("\(values)")
},
cancel: { ActionMultipleStringCancelBlock in return },
origin: sender)