How To get values of textfields from a UITableViewCell?

后端 未结 6 1636
天命终不由人
天命终不由人 2021-01-01 02:13

So I have thisUITableView cell that has 4 UITextField, and I want to get their values on button click.

This code does not retrieve any valu

6条回答
  •  -上瘾入骨i
    2021-01-01 02:24

    func textField(_ textField: UITextField, shouldChangeCharactersIn range:NSRange, replacementString string: String) -> Bool {
        //        let kActualText = (textField.text ?? "") + string
    
        var kActualText = (textField.text! as NSString).replacingCharacters(in: range, with: string)
    
        kActualText = kActualText.trimmingCharacters(in: .whitespaces)
    
        if textField.tag == 0
        {
            email_address = kActualText;
        }
        else if textField.tag == 3
        {
            password = kActualText;
        }
        else
        {
            print("It is nothing")
        }
    
        return true;
    }
    

提交回复
热议问题