【问题标题】:Remove separator line of single row in Eureka删除尤里卡中单行的分隔线
【发布时间】:2017-01-02 10:36:47
【问题描述】:

如何删除 Eureka 表单中单行的分隔线?

我想删除表格视图中的最后一行,即描述行下方的那一行。当我用常规的 tableview 寻找这个问题的解决方案时,最流行的解决方案是通过设置一个大的分隔符插入来将特定单元格的分隔线推出屏幕。像这样:

form.last! <<< TextAreaRow("description row") {
    $0.placeholder = "Description of the issue"
    $0.textAreaHeight = .dynamic(initialTextViewHeight: 44)
}.cellSetup{ cell, row in
    cell.separatorInset = UIEdgeInsets(top: 0, left: 2000, bottom: 0, right: 0)
}.onChange{ [weak self] in
    self?.issueMessage = $0.value ?? ""
}

我在viewDidLoad 上调用它,但它似乎没有任何效果。我是 Eureka 的新手。

【问题讨论】:

  • 你有没有试过设置单元格的分隔符样式?? self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone
  • 是的。它是 tableview 上的一个属性。它删除了所有单元格上的分隔线,这不是我想要的。
  • 你找到解决办法了吗?

标签: ios swift uitableview eureka-forms


【解决方案1】:

试试这个代码:

form.last! <<< TextAreaRow("description row") {
            $0.placeholder = "Description of the issue"
            $0.textAreaHeight = .dynamic(initialTextViewHeight: 44)
        }.cellSetup{ (cell, row) in
            if(row != 3) {
                cell.separatorInset = UIEdgeInsets(top: 0, left: 2000, bottom: 0, right: 0)
            }
        }.onChange{ [weak self] in
            self?.issueMessage = $0.value ?? ""
        }

考虑到您只有 4 行,我添加了检查 (row != 3),第 4 行的索引将是 3,因为它以 0 开头。

【讨论】:

  • 这有什么改变?
  • 您想删除第 4 项的行,这意味着行将是 3。所以我们可以保持更改 if(row != 3) 然后设置 separatorInset 否则不。所以它将显示 0,1,2 单元格的分隔符,而不是 3
【解决方案2】:

斯威夫特 4、5

layoutSubview

public override func layoutSubviews() {
        super.layoutSubviews()
        for view in self.subviews where view != self.contentView {
            if NSStringFromClass(type(of: view)).contains("_UITableViewCellSeparatorView")
                view.removeFromSuperview()
            }
        }
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-08-02
    • 1970-01-01
    • 2021-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-26
    • 2017-03-12
    相关资源
    最近更新 更多