gpt4 book ai didi

Swift - 使用 Eureka 获取 textField 表单的值

转载 作者:行者123 更新时间:2023-11-28 05:56:48 25 4
gpt4 key购买 nike

我正在做一个 Eureka 表单的应用程序,问题是我不知道如何获取第一个 textField 的值。

问题是我应该获取第一部分 DecimalRow 的值,我应该将它与第二部分 KalkulationCell(这是一个自定义单元格)的 textField 相乘,但我不知道如何合并这些部分。

import UIKit
import Eureka

class ViewController: FormViewController {

override func viewDidLoad() {
super.viewDidLoad()

//var rules = RuleSet<String>()

form +++ Section("EINGABESUMME BRUTTO (EXXL MWST)")

{$0.header?.height = { 20 }}
<<< DecimalRow(){
$0.title = " "
//$0.value = 54
$0.tag = "MyRowTag"

}

.cellUpdate { cell, row in
cell.textField?.font = .boldSystemFont(ofSize: 18.0)

}



let row: DecimalRow? = form.rowBy(tag: "MyRowTag")
let value = row?.value

// Get the value of all rows which have a Tag assigned
// The dictionary contains the 'rowTag':value pairs.
let valuesDictionary = form.values()
print(valuesDictionary)




form +++ Section("ZIEL-DB PROJEKT BRUTTO")
{
$0.header?.height = { 20 }

}

<<< KalkulationRow {
row in
row.cell.valueField.text = "54.00"

row.tag="hello"
}




form +++ Section("RABATT")
{
$0.header?.height = { 20 }

}
<<< KalkulationRow { row in
row.cell.valueField.text = "54.00"

}


form +++ Section("SKONTO")
{
$0.header?.height = { 20 }

}

<<< IntRow(){
$0.title = "Tage:"
$0.placeholder = "2"
$0.add(rule: RuleRequired())

}
.cellUpdate { cell, row in

cell.textField?.font = .boldSystemFont(ofSize: 18.0)
}
<<< KalkulationRow { row in
row.cell.valueField.text = "54.00"
}
form +++ Section("DIVERSE ABZUGE")
{
$0.header?.height = { 20 }

}
<<< KalkulationRow { row in
row.cell.valueField.text = "54.00"
}



form +++ Section("EINGABESSUME NETTO")
{
$0.header?.height = { 20 }

}
<<< DecimalRow(){
$0.title = " "
$0.value = 54.00
$0.placeholderColor = UIColor.green


}
.cellUpdate { cell, row in
cell.textField?.font = .boldSystemFont(ofSize: 18.0)
cell.textField?.textColor = UIColor.green
cell.textField?.isUserInteractionEnabled = false
}


form +++ Section("ZIEL-DB PROJEKT NETTO")
{
$0.header?.height = { 20 }

}

<<< KalkulationRow { row in
row.cell.valueField.text = "54.00"
}


}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()

}


}

最佳答案

正如 vadian 所建议的,您可以使用 onChange 方法检测文本更改,如下所示:

.onChange({ decimal in

print(decimal)
})

最终代码为:

{
$0.header?.height = { 20 }

}
<<< DecimalRow(){
$0.title = " "
$0.tag = "MyRowTag"

}
.onChange({ decimal in

print(decimal)
})
.cellUpdate { cell, row in
cell.textField?.font = .boldSystemFont(ofSize: 18.0)
}

关于Swift - 使用 Eureka 获取 textField 表单的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51281234/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com