我有一个与按钮链接的pickerView 当你点击按钮时它会出现..
我的问题是: 我不知道如何获得结果并将其打印到我创建的textFiled ..
如果我可以在按钮名称中生成结果而不需要文本提交将会很棒!!
这就是我到目前为止所做的:
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)
}
答案 0 :(得分:0)
我认为在将值分配给文本字段时,doneBlock
中的变量名称出错了。另外,请查看initialSelection
参数。您已提供[1]
,它将选择整个数组。
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)