gpt4 book ai didi

swift - 选择器 View 不显示数组数据

转载 作者:行者123 更新时间:2023-11-28 10:31:07 25 4
gpt4 key购买 nike

var Months = ["A","B","C","D"]
var pickerview = UIPickerView()
@IBOutlet var txt_Month: UITextField!

override func viewDidLoad() {
super.viewDidLoad()

pickerview.isHidden = true
pickerview.dataSource = self
pickerview.delegate = self

txt_Month.inputView = pickerview
}

func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 1
}

func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return Months.count
}

func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int)
{
txt_Month.text = Months[row]
}

func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String?
{
return Months[row]
}

最佳答案

可能是因为pickerview被隐藏了?

关于swift - 选择器 View 不显示数组数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55899583/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com