如何将标签文本添加到DetailDisclosureButton?

ded*_*ded 8 uitableview accessoryview ios swift

我正在使用iOS Swift 2.0应用程序.我无法弄清楚我的生活如何UITableViewCell在披露指标雪佛龙之前的右侧设置文本(除了创建自定义cell.accessoryView).

这是"设置应用程序"的屏幕截图,正是我正在努力实现的目标.

细胞配件视图截图

Dav*_*ton 10

在Interface Builder中,设置单元格时,选择右侧详细信息样式:

正确的细节

然后将值赋给detailTextLabel属性:

cell.detailTextLabel.text = "Kilroy Was Here"
Run Code Online (Sandbox Code Playgroud)


Dmi*_*kov 7

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    let cell = tableView.dequeueReusableCell(withIdentifier: "CellId") ?? UITableViewCell(style: UITableViewCellStyle.value1, reuseIdentifier: "CellId")
    cell.accessoryType = UITableViewCellAccessoryType.disclosureIndicator
    cell.textLabel?.text = "Main text"
    cell.detailTextLabel?.text = "Detail Text"

    return cell
}
Run Code Online (Sandbox Code Playgroud)