[英]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.