Eureka 中的动态 TextRow
Dynamic TextRow in Eureka
我正在尝试做一个 SegmentedRow。在每个部分中,都有 TextRow。这些 TextRows 在数量上是动态的。我试过了:
+++ Section()
<<< SegmentedRow<String>("segments"){
[=10=].options = ["Assets", "Notes", "Photos"]
[=10=].value = "Assets"
}
+++ Section(){
[=10=].tag = "assets_s"
[=10=].hidden = "$segments != 'Assets'" // .Predicate(NSPredicate(format: "$segments != 'Sport'"))
}
for t in myarray{
<<< TextRow(){
[=10=].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"){
[=10=].options = ["Assets", "Notes", "Photos"]
[=10=].value = "Assets"
}.onChange({ (segmented) in
if(segmented.value == "Assets")
{
segmented.section!.removeLast(segmented.section!.count - 1)
for value in assets
{
segmented.section! <<< TextRow(){
[=10=].title = value
}
}
}
if(segmented.value == "Notes")
{
segmented.section!.removeLast(segmented.section!.count - 1)
for value in notes
{
segmented.section! <<< ButtonRow(){
[=10=].title = value
}
}
}
if(segmented.value == "Photos")
{
segmented.section!.removeLast(segmented.section!.count - 1)
for value in photos
{
segmented.section! <<< TextRow(){
[=10=].title = value
}
}
}
})
}
}
希望对您有所帮助
我正在尝试做一个 SegmentedRow。在每个部分中,都有 TextRow。这些 TextRows 在数量上是动态的。我试过了:
+++ Section()
<<< SegmentedRow<String>("segments"){
[=10=].options = ["Assets", "Notes", "Photos"]
[=10=].value = "Assets"
}
+++ Section(){
[=10=].tag = "assets_s"
[=10=].hidden = "$segments != 'Assets'" // .Predicate(NSPredicate(format: "$segments != 'Sport'"))
}
for t in myarray{
<<< TextRow(){
[=10=].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"){
[=10=].options = ["Assets", "Notes", "Photos"]
[=10=].value = "Assets"
}.onChange({ (segmented) in
if(segmented.value == "Assets")
{
segmented.section!.removeLast(segmented.section!.count - 1)
for value in assets
{
segmented.section! <<< TextRow(){
[=10=].title = value
}
}
}
if(segmented.value == "Notes")
{
segmented.section!.removeLast(segmented.section!.count - 1)
for value in notes
{
segmented.section! <<< ButtonRow(){
[=10=].title = value
}
}
}
if(segmented.value == "Photos")
{
segmented.section!.removeLast(segmented.section!.count - 1)
for value in photos
{
segmented.section! <<< TextRow(){
[=10=].title = value
}
}
}
})
}
}
希望对您有所帮助