Reputation: 11
Currently, I am getting this result using a ButtonRow by adding a label view to the cell:
<<< ButtonRow("Email") {
$0.title = $0.tag
$0.presentationMode = PresentationMode.Show(...)
}.cellSetup {
cell, row in
let text = UILabel(frame: cell.frame)
text.frame.size.width = 0.909 * currentScreenWidth - 68
text.frame.origin.x = 68
text.textColor = UIColor(red: 142/255, green: 142/255, blue: 147/255, alpha: 1)
text.textAlignment = .Right
text.text = "[email protected]"
cell.addSubview(text)
}
I am using ButtonRow because it has that little ">" at the end, and it works great when presenting a new view and view controller programmatically.
Using $0.value = "Some String"
does not work, like it does with other properties.
Is there anyway to do this without having to manually add a label view? It works in all screens, but nevertheless I don't think it's very safe to manually set those parameters.
Upvotes: 1
Views: 1170
Reputation: 61
The implementation of ButtonRow uses UITableViewCellStyle 'default' when initializing the cell object. You can create a subclass of ButtonRow:
public final class DetailedButtonRowOf<T: Equatable> : _ButtonRowOf<T>, RowType {
public required init(tag: String?) {
super.init(tag: tag)
cellStyle = .value1
}
}
public typealias DetailedButtonRow = DetailedButtonRowOf<String>
Then you can specify the detailLabelText of the row:
<<< DetailedButtonRow("Email") { row in
row.title = row.tag
row.presentationMode = .segueName(segueName: "AStoryboardSegue", onDismiss: nil)
}.cellUpdate({ (cell, row) in
cell.detailTextLabel?.text = "[email protected]"
})
Upvotes: 6