I am trying to do a SegmentedRow. And in each section, there are TextRows. These TextRows are dynamic in number. I tried:
+++ 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?"
}
}
I tried putting the for loop there but I get an error in the succeeding lines.
i think that what you need is something like this, and this is how it looks
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
}
}
}
})
}
}
I hope this helps you