SWIFT无法获取动态视图的总数按钮单击。
当我在一个自定义动态视图(TextField)中输入数据时,在另一个Cust-Dynamic视图(TextField)中输入数据。
我希望TextField Outside中的这两个Txt字段的总和。
如果你可以在底部看到整体Sqft有总和文本字段,并且Cust-Dynamic View的数量被称为所有文本字段的总和结果需要在整体sqft TextField中更新。 例如:99 + 99 = 198.00 提前致谢。
func viewcall()
{
// for _ in 0..<count {
myView = customSubView(frame: CGRect(x: 100, y: 220+y_value, width: 400, height: 245))
myView.backgroundColor = UIColor(white: 1, alpha: 0.5)
myView.layer.cornerRadius = 15
myView.Board_height.addTarget(self, action: #selector(didChangeText(textField:)), for: .editingChanged)
myView.actionButton.addTarget(self, action: (#selector(cancelbutton(_:))), for: UIControlEvents.touchUpInside)
myView.NoofBoardtext.addTarget(self, action:#selector(didChangeTexts(textField:)), for: .editingChanged)
myView.numberofdays.addTarget(self, action:#selector(dayscalculation(textField:)), for: .editingChanged)
self.scrlview.addSubview(myView)
}
func didChangeText(textField: UITextField)
{
myView.Board_total.text = String(Int(myView.Board_size.text!)! * Int(myView.Board_height.text!)!)
}
//only Calculation for total SQFT
func didChangeTexts(textField: UITextField)
{
myView.totalSQFT.text = String(Int(myView.NoofBoardtext.text!)! * Int(myView.Board_total.text!)!)
}
//only Calculation for total SQFT
func dayscalculation(textField: UITextField)
{
myView.totalDays.text = myView.numberofdays.text!
myView.Totalsqfttext.text = String(Int(myView.totalSQFT.text!)! * Int(myView.numberofdays.text!)!)
overallSQFTtext.text = myView.Totalsqfttext.text
}