我的Eureka表格有StepperRow。
var n = 1
form +++ Section("")
<<< TextRow(){ row in
row.title = "Meal Plan Name"
row.placeholder = "Name"
row.cell.textField.autocapitalizationType = .none
}
<<< StepperRow().cellSetup({ (cell, row) in
row.title = "Number of Meals Per Day"
row.tag = "df"
row.value = 1
cell.valueLabel!.text = "\(Int(row.value!))"
}).cellUpdate({ (cell, row) in
if(row.value != nil)
{
cell.valueLabel!.text = "\(Int(row.value!))"
}
}).onChange({ (row) in
if(row.value != nil)
{
row.cell.valueLabel!.text = "\(Int(row.value!))"
if let mealSec = self.form.sectionBy(tag: "mealSection"){
if let mRow = self.form.rowBy(tag: "MealRow"){
mealSec.append(mRow)
mRow.reload()
}
}
}
print("value changed")
})
我尝试获取另一部分行的标签,并将行附加到“ StepperRow”的更改上,如上所示。但这没有用。我想更新另一部分。这是我要更新的多值部分。
form +++
MultivaluedSection(multivaluedOptions: [.Reorder, .Insert, .Delete],
header: "Meals"
) {
$0.addButtonProvider = { section in
return ButtonRow(){
$0.title = "Add New Meal"
}
}
$0.tag = "mealSection"
$0.multivaluedRowToInsertAt = { index in
return ButtonRow("MealRow"){
$0.title = "Meal \(n)"
$0.cellStyle = .value1
$0.tag = "MealRow"
n+=1
print(n)
}.cellUpdate { cell, _ in
cell.accessoryType = .disclosureIndicator
cell.tintColor = .black
}.onCellSelection { _, _ in
// Instatiating and presenting the view controller
let webView = MealVC()
self.navigationController?.pushViewController(webView, animated: true)
}
}
$0 <<< ButtonRow(){
$0.title = "Meal 1"
$0.cellStyle = .value1
n+=1
print(n)
}.cellUpdate { cell, _ in
cell.accessoryType = .disclosureIndicator
cell.tintColor = .black
}
}
在StepperRow更改时,应在多值部分中添加新餐行。