How to add label text to DetailDisclosureButton?

I am working in an iOS Swift 2.0 application. I can’t understand for myself how to set the text on the right side of the UITableViewCell immediately before the chevron expansion character (besides creating a custom cell.accessoryView ).

Here is a screenshot of the “Application Settings” doing exactly what I am trying to achieve.

cell accessory screenshot

+7
ios uitableview swift accessoryview
source share
2 answers

In the Builder interface, when setting up the cell, select the "Correct part" style:

Right detail

Then assign the value to the detailTextLabel property:

 cell.detailTextLabel.text = "Kilroy Was Here" 
+7
source share
 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 } 
+3
source share

All Articles