2016-06-28 112 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 /自排功能于尤里卡 –