2

無駄な質問かもしれませんが、labelRowで「forループ」を作ろうとしているのですが、思い通りになりません。

SegmentedRow を使用した Eureka のサンプル プロジェクトと同じことが必要ですが、セグメントでは行のループを実行したいと考えています。

誰かが私を案内できますか?

これは私がロードしたビューで試したものです:

 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!

しかし、次のようなエラーが発生しました。

エラーの写真

4

2 に答える 2

4

最後に答えを見つけました!

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"
    }
}
于 2016-06-27T15:47:48.420 に答える