ios - swift Eureka : Adding text value to ButtonRow

标签 ios swift cocoapods eureka-forms

目前,我通过向单元格添加标签 View 使用 ButtonRow 获得此结果:

enter image description here

<<< 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 = "fakeEmail@email.com"
                cell.addSubview(text)
 }

我正在使用 ButtonRow,因为它在末尾有一个小“>”,并且在以编程方式呈现新 View 和 View Controller 时效果很好。

使用 $0.value = "Some String" 不起作用,就像它对其他属性一样。

有没有办法不用手动添加标签 View 就可以做到这一点?它适用于所有屏幕,但我认为手动设置这些参数并不是很安全。

最佳答案

ButtonRow 的实现在初始化单元格对象时使用 UITableViewCellStyle 'default'。您可以创建 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>

然后可以指定该行的detailLabelText:

<<< DetailedButtonRow("Email") { row in
    row.title = row.tag
    row.presentationMode = .segueName(segueName: "AStoryboardSegue", onDismiss: nil)
}.cellUpdate({ (cell, row) in
    cell.detailTextLabel?.text = "fakeEmail@email.com"
})

关于ios - swift Eureka : Adding text value to ButtonRow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38189640/

相关文章:

swift - 将 SCNScene 分配给 SCNView - 在展开可选值时发现 nil

ios - 使用 ReplayKit 流式传输时从 CMSampleBuffer 保存视频

ios - 动画:使用 Autolayout、Frame.Origin 和 Broken Constraints,还是第三种选择?

ios - pods 安装问题

ios - SKScene 中的 AdMob 奖励视频

ios - 如何修复此无效更新 : invalid number of rows in section 0 error?

ios - 如何更改 swift 4 中图像文件中存储的值

ios - 如何关闭 iOS 中 HTML 表单字段的自动大写?

ios - cocoapods swift 没有这样的模块

ios - 升级到 XCode 9.1,命令/bin/sh 失败,退出代码 1 错误