我正在使用Eureka form,用户在其中选择日期。当用户选择第一个日期时,我想更新第二行中的第二个日期(将第一天添加30天)。
<<< DateRow(){
$0.value = Date()
$0.title = "First Date"
$0.tag = "firstDate"
.onChange({ (row) in
<< update secondDate = firstDate + 30 days >>
} )
<<< DateRow(){
$0.value = Date()
$0.title = "Second Date"
$0.tag = "secondDate"
我怎样才能做到这一点?
答案 0 :(得分:5)
请找到以下解决方案。
func createSection() {
let section = Section("Section2") { section in
section.header?.height = { 40 }
}
<<< DateRow() {
$0.value = Date()
$0.title = "First Date"
$0.tag = "First"
}.onChange({ (row) in
let secondRow = self.form.rowBy(tag: "Second") as! DateRow
let date = row.value!
let newDate = date.addingTimeInterval(30*24*60*60)
secondRow.value = newDate
secondRow.reload()
})
<<< DateRow() {
$0.value = Date()
$0.title = "Second Date"
$0.tag = "Second"
}.onChange({ (row) in
})
form +++ section
}
如有任何疑问,请与我联系。