简体   繁体   English

在 Eureka 中隐藏一行,具体取决于它是否包含值

[英]Hiding a row in Eureka depending if it contains a value or not

I made a form with Eureka and was wondering how to hide a row or section depending if it contains a value or not:我用Eureka制作了一个表格,想知道如何隐藏一行或部分,具体取决于它是否包含值:

form
            +++ Section("Car")
            <<< TextRow() {
                $0.title = car?.name
            }
            +++ Section("Car color")
            <<< TextRow() {
                $0.title = car?.color
            }
            +++ Section("Car description")
            <<< TextRow() {
                $0.title = car?.description
                $0.cell.textLabel?.numberOfLines = 0
            }
            +++ Section("Car brand")
            <<< TextRow() {
                $0.title = car?.brandName
            }
          +++ Section("Comment")
            <<< TextRow() {
            $0.tag = "Comment"
               $0.title = car?.internComment
                $0.cell.textLabel?.numberOfLines = 0
                $0.hidden = Condition.function([])
                { form in
                    if (form.rowBy(tag: "Comment") as? TextRow) != nil {
                       return false
                    }
                    return true
                }
        }

I tried it with我试过了

$0.hidden = Condition.function([])
                { form in
                    if (form.rowBy(tag: "Comment") as? TextRow) != nil {
                       return false
                    }
                    return true
                }

but it is hiding it regardless if it contains a value or not.但无论它是否包含值,它都会隐藏它。

You are checking for the row itself, check for its value您正在检查行本身,检查它的

$0.hidden = Condition.function([]) { form in
   if (form.rowBy(tag: "Comment") as? TextRow)?.value != nil {
      return false
   }
   return true
}

or shorter或更短

$0.hidden = Condition.function([]) { form in
    return !((form.rowBy(tag: "Comment") as? TextRow)?.value ?? false)
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM