gpt4 book ai didi

swift - UIPickerView 滚动行消失

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

我已经搜索过,但我还没有找到解决方案,我有一个 UIPickerView,当我开始查看时工作正常,当我滚动行时消失

class SemanaViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, UIPickerViewDataSource, UIPickerViewDelegate {

let letters = ["A","B","C","D","F","G","H"]

@IBOutlet weak var pickerView: UIPickerView!

override func viewDidLoad() {
super.viewDidLoad()
self.tableView.delegate = self
self.tableView.dataSource = self
self.pickerView.dataSource = self
self.pickerView.delegate = self
....
}
....
func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 1
}

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


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

func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView {

let pickerLabel = UILabel()
//pickerLabel.textColor = UIColor.red
pickerLabel.text = letters[row]

return pickerLabel
}

打印

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

有什么建议吗?谢谢

最佳答案

根据我创建 View 的方式,我发现错误正在发生。

我有一个 UISegmentedControl 和 2 个 subview (UIViewController),错误发生在 1 个 subview (SemanalmenteViewController),我已经更改了此作品的 subview 创建方式。

我不知道,但我认为这与父 View Controller 有关。

关于swift - UIPickerView 滚动行消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48878340/

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