簡體   English   中英

尤里卡中的動態 TextRow

[英]Dynamic TextRow in Eureka

我正在嘗試做一個 SegmentedRow。 並且在每個部分中,都有 TextRows。 這些 TextRow 的數量是動態的。 我試過:

 +++ Section()
            <<< SegmentedRow<String>("segments"){
                $0.options = ["Assets", "Notes", "Photos"]
                $0.value = "Assets"
            }
            +++ Section(){
                $0.tag = "assets_s"
                $0.hidden = "$segments != 'Assets'" // .Predicate(NSPredicate(format: "$segments != 'Sport'"))
            }
            for t in myarray{
                <<< TextRow(){
                $0.title = "Which is your favourite soccer player?"
            }

            }

我嘗試將 for 循環放在那里,但在隨后的行中出現錯誤。

我認為你需要的是這樣的,這就是它的樣子

在此處輸入圖片說明

class ViewController2: FormViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let assets = [String](arrayLiteral: "asset1","asset2","asset3")
        let notes = [String](arrayLiteral: "note1","note2","note3")
        let photos = [String](arrayLiteral: "photo1","photo2","photo3")
        // Do any additional setup after loading the view.

        form  +++ Section()
            <<< SegmentedRow<String>("segments"){
                $0.options = ["Assets", "Notes", "Photos"]
                $0.value = "Assets"
                }.onChange({ (segmented) in
                    if(segmented.value == "Assets")
                    {
                        segmented.section!.removeLast(segmented.section!.count - 1)

                        for value in assets
                        {
                            segmented.section! <<< TextRow(){
                                $0.title = value
                            }
                        }
                    }
                     if(segmented.value == "Notes")
                    {
                        segmented.section!.removeLast(segmented.section!.count - 1)

                        for value in notes
                        {
                            segmented.section! <<< ButtonRow(){
                                $0.title = value
                            }
                        }
                    }

                    if(segmented.value == "Photos")
                    {
                        segmented.section!.removeLast(segmented.section!.count - 1)

                        for value in photos
                        {
                            segmented.section! <<< TextRow(){
                                $0.title = value
                            }
                        }
                    }
                })

    }

}

我希望這對你有幫助

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM