12

我正在使用 iOS Swift 2.0 应用程序。UITableViewCell我一生都无法弄清楚如何在披露指示符 chevron 之前的右侧设置文本(除了创建 custom cell.accessoryView)。

这是“设置应用程序”的屏幕截图,正是我想要实现的。

细胞附件视图截图

4

2 回答 2

13

在 Interface Builder 中,设置单元格时,选择 Right Detail 样式:

正确的细节

然后将值分配给detailTextLabel属性:

cell.detailTextLabel.text = "Kilroy Was Here"
于 2016-02-15T01:38:43.807 回答
12
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
}
于 2016-11-29T15:59:40.437 回答