gpt4 book ai didi

swift - 如何给 UITableview 添加二级标签

转载 作者:行者123 更新时间:2023-11-28 06:02:52 25 4
gpt4 key购买 nike

我想知道如何将辅助 UILabel 添加到 UITableViewCell,辅助标签是指单元格右侧的灰色标签,我已经尝试过:

`cell.detailTextLabel?.text = "TEST"`

但是这段文字没有出现,我想要这样的东西:

I want something like this

最佳答案

用适当的样式初始化一个UITableViewCell,使detailTextLabel可用,例如:

let cell = UITableViewCell(style: UITableViewCellStyle.value1, reuseIdentifier: "SOME_CELL_IDENTIFIER")

使用 xib,您可以从 Attributes Inspector 执行此操作,将 Style 设置为 Right Detail:

现在,如果您尝试您的代码,它应该可以工作:

cell.detailTextLabel?.text = "TEST"

关于swift - 如何给 UITableview 添加二级标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49075768/

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