gpt4 book ai didi

ios - swift 3 : UILabel not showing in custom UITableViewCell

转载 作者:搜寻专家 更新时间:2023-10-30 23:09:04 26 4
gpt4 key购买 nike

我有一个名为 CCLineupTableViewCell 的自定义 UITableViewCell,如下所示:

@IBOutlet weak var artistNameLabel: UILabel!
@IBOutlet weak var artistValuationLabel: UILabel!

override func awakeFromNib() {
super.awakeFromNib()
// Initialization code

}

override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)

// Configure the view for the selected state
}

我在 cellForRowAt indexPath: IndexPath 方法中访问单元格,如下所示:

let cell = tableView.dequeueReusableCell(withIdentifier: "HomeCell", for: indexPath) as! CCLineupTableViewCell

我的自定义单元设置是这样的:

enter image description here

enter image description here

如您所见,它是在 IB 和代码中设置的。奇怪的是,第一个标签 artistNameLabel 可通过 cellForRowAt indexPath: IndexPath 访问,并且工作完美。然而,artistValuationLabel 甚至从未出现,尽管 Storyboard中有默认文本。

编辑:

我已经添加了 Nib 约束的图片。它固定在单元格的右侧、顶部和底部(以及纵横比)。

enter image description here

最佳答案

你的错误是你设置的约束有误。

添加宽度约束以确保 artistValuationLabel 有空间显示。

关于ios - swift 3 : UILabel not showing in custom UITableViewCell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43172276/

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