var monthsOfNonWorking = ["1. mēnesis","2. mēnesis","3. mēnesis","4. mēnesis","5. mēnesis","6. mēnesis","7. mēnesis","8. mēnesis","9. mēnesis",]
@IBAction func nonWorkingAllowanceCalculate(_ sender: Any) {
var firstThreeMonths :Double
var secondThreeMonths :Double
var LastThreeMonths :Double
let bezdarbienieka_alga = Double(bezd_alga.text!)
if (staza_masiva_lasisana == 0) {
firstThreeMonths = Double(bezdarbienieka_alga! / 2)
secondThreeMonths = Double(firstThreeMonths / 2)
LastThreeMonths = Double(bezdarbienieka_alga! / 1.6 - secondThreeMonths) }}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! MonthTableViewCell
switch indexPath.row {
case 0: cell.nonWorkingAllowance?.text = String()
}
cell.monthLabel?.text = monthsOfNonWorking[indexPath.row]
return cell
}
如何使用按钮操作计算后在表格视图单元格上显示结果?
例如,我想在firstThreeMonths
上显示数据tableViewCell
?
答案 0 :(得分:2)
只需在按钮操作的末尾添加tableView.reloadData()
。
@IBAction func nonWorkingAllowanceCalculate(_ sender: Any) {
var firstThreeMonths :Double
var secondThreeMonths :Double
var LastThreeMonths :Double
let bezdarbienieka_alga = Double(bezd_alga.text!)
if (staza_masiva_lasisana == 0) {
firstThreeMonths = Double(bezdarbienieka_alga! / 2)
secondThreeMonths = Double(firstThreeMonths / 2)
LastThreeMonths = Double(bezdarbienieka_alga! / 1.6 - secondThreeMonths)
}
tableView.reloadData()
}