swift - Swift 中的 Eureka 库 : How can I loop rows?

标签 swift uitableview for-loop rows eureka-forms

也许这是一个无用的问题,但我试图用 labelRow 创建一个“for 循环”,但它没有做我想要的事情。

我想要与带有 SegmentedRow 的 Eureka 示例项目相同的东西,但在段中我想对行进行循环。

有人可以指导我吗?

这是我在 View 中尝试加载的内容:

 self.form = Section()
        <<< SegmentedRow<String>("segments"){
            $0.options = ["Passées", "En cours", "Futures"]
            $0.value = "En cours"
        }
        
        +++ Section(){
            $0.tag = "past_s"
            $0.hidden = "$segments != 'Passées'" // .Predicate(NSPredicate(format: "$segments != 'Sport'"))
    }
    
    for it in self.past {
        self.form.last! <<< TextRow() { row in
            row.title = "Which is your favourite soccer player?"
        }
    }
    
    self.form +++= Section(){
        $0.tag = "waiting_s"
        $0.hidden = "$segments != 'En cours'"
    }
    
    for it in self.waiting {
        self.form.last! <<< TextRow() { row in
            row.title = "Which is your favourite soccer player?"
        }
    }
    
    self.form +++= Section(){
        $0.tag = "futur_s"
        $0.hidden = "$segments != 'Futures'"
    }
    
    for it in self.future {
        self.form.last! <<< TextRow() { row in
            row.title = "Which is your favourite soccer player?"
        }
    }

这就是我正在等待的:)

self.form = Section()
    <<< SegmentedRow<String>("segments"){
        $0.options = ["Passées", "En cours", "Futures"]
        $0.value = "En cours"
    }
    
    +++ Section(){
        $0.tag = "past_s"
        $0.hidden = "$segments != 'Passées'" // .Predicate(NSPredicate(format: "$segments != 'Sport'"))
    }
    
    <<< LabelRow() { row in
        row.title = "1"
    }
    
    <<< LabelRow() { row in
        row.title = "temp"
    }
    
    +++ Section(){
        $0.tag = "waiting_s"
        $0.hidden = "$segments != 'En cours'"
    }
    
    <<< LabelRow() { row in
        row.title = "2"
    }
    
    <<< LabelRow() { row in
        row.title = "temp"
    }
    
    +++ Section(){
        $0.tag = "futur_s"
        $0.hidden = "$segments != 'Futures'"
    }
    
    <<< LabelRow() { row in
        row.title = "3"
    }
    
    <<< LabelRow() { row in
        row.title = "temp"
}
    

我也尝试过(以及很多其他方法):

form +++ Section()
form.last! <<< SegmentedRow<String>("segments"){
    $0.options = ["Passées", "En cours", "Futures"]
    $0.value = "En cours"
}

form +++= Section(){
    $0.tag = "past_s"
    $0.hidden = "$segments != 'Passées'"
}

for past in self.past {
    form.last! <<< LabelRow() { row in
        row.title = "1"
    }
}

也试试这个:

form = Section()
    <<< SegmentedRow<String>("segments"){
        $0.options = ["Passées", "En cours", "Futures"]
        $0.value = "En cours"
}

form +++ self.pastSection!
form +++ self.waitingSection!
form +++ self.futurSection!

self.pastSection = Section("past_s") {
    $0.tag = "past_s"
    $0.hidden = "$segments != 'Passées'"
}

self.waitingSection = Section("waiting_s") {
    $0.tag = "waiting_s"
    $0.hidden = "$segments != 'En cours'"
}

self.futurSection = Section("futur_s") {
    $0.tag = "futur_s"
    $0.hidden = "$segments != 'Futures'"
}

for past in self.past {
    self.pastSection!
        <<< LabelRow() {
            $0.title = "test"
    }
}

for waiting in self.waiting {
    self.waitingSection!
        <<< LabelRow() {
            $0.title = "test"
    }
}

for futur in self.future {
    self.futurSection!
        <<< LabelRow() {
            $0.title = "test"
    }
}

form +++ self.pastSection!
form +++ self.waitingSection!
form +++ self.futurSection!

但是我遇到了这样的错误:

photo of error

最佳答案

终于找到答案了!

form.delegate = nil
form.removeAll()

form +++= Section("DuplicateCounter") { row in row.tag = "DuplicateCounter" }

    <<< SegmentedRow<String>("segments"){
        $0.options = ["Passées", "En cours", "Futures"]
        $0.value = "En cours"
}

self.pastSection = Section("past_s") {
    $0.tag = "past_s"
    $0.hidden = "$segments != 'Passées'"
}

self.waitingSection = Section("waiting_s") {
    $0.tag = "waiting_s"
    $0.hidden = "$segments != 'En cours'"
}

self.futurSection = Section("futur_s") {
    $0.tag = "futur_s"
    $0.hidden = "$segments != 'Futures'"
}

form +++ self.pastSection!
form +++ self.waitingSection!
form +++ self.futurSection!

for past in self.past {
    self.pastSection!
        <<< LabelRow("\(past.id)") {
            $0.title = "test"
    }
}

for waiting in self.waiting {
    self.waitingSection!
        <<< LabelRow("\(waiting.id)") {
            $0.title = "test"
    }
}

for futur in self.future {
    self.futurSection!
        <<< LabelRow("\(futur.id)") {
            $0.title = "test"
    }
}

关于swift - Swift 中的 Eureka 库 : How can I loop rows?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38017327/

相关文章:

c# - 重复消除分配

ios - Swift - 仅允许在 iPad 上旋转

ios - 如何计算不同时区的两个 NSDate 对象之间的天数差异?

ios - 如何在 UITableView 中设置分隔符的全宽

objective-c - 我想实现一半 UITableView 一半 MapView UIView,中间有一个按钮

ios - UITableViewCell UILabel 多行对齐

python - Python 中的数据框值匹配

没有 for 循环的 R 二进制详尽列表

swift - 合并/追加两个文件

ios - 将 subview 固定到 stackview 的前缘和后缘