[英]Hiding a row in Eureka 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
}
}
我试过了
$0.hidden = Condition.function([])
{ form in
if (form.rowBy(tag: "Comment") as? TextRow) != nil {
return false
}
return true
}
但无论它是否包含值,它都会隐藏它。
您正在检查行本身,检查它的值
$0.hidden = Condition.function([]) { form in
if (form.rowBy(tag: "Comment") as? TextRow)?.value != nil {
return false
}
return true
}
或更短
$0.hidden = Condition.function([]) { form in
return !((form.rowBy(tag: "Comment") as? TextRow)?.value ?? false)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.