2016-06-28 103 views
0

我試圖做一個SegmentedRow。在每個部分都有TextRows。這些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循環放在那裏,但是在後續行中出現錯誤。

+0

你可以發佈什麼是myArray的? –

回答

1

我認爲你需要的是這樣的事情,這是它的外觀

enter image description here

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 
          } 
         } 
        } 
       }) 

    } 

} 

我希望這有助於你

+0

我想知道您是否嘗試過創建自定義行?像一個有UIImage視圖的行? –

+0

檢查這也許可以幫助你http://stackoverflow.com/questions/37767816/how-to-create-custom-inline-rows-with-eureka/37998235#37998235 –

+0

我創建了一個問題:HTTP://計算器.COM /問題/ 38188514 /自排功能於尤里卡 –

相關問題