我当前正在创建一个应用程序,我正在登录和注册功能的atm。我决定在其中有文本字段的地方创建一个表格视图,以便用户可以注册。但是每次我在文本字段中输入内容并向下滚动时,这些文本字段都会被清除,但是为什么呢?
此外,当我点击按钮时如何将这些数据添加到数据库中?由于我无法从那里到达。有输入吗?
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "signUpCell", for: indexPath) as! SignUpTableViewCell
cell.txtfield.delegate = self
cell.textOfField.text = textNames[indexPath.section][indexPath.row]
cell.txtfield.text = textFields[indexPath.section][indexPath.row]
@IBAction func signUpButtonTapped(_ sender: Any)
{
let authentication = Auth.auth().currentUser?.uid
//I know how to add it to the database, but how can I retrieve the tableview data here?
}
答案 0 :(得分:0)
单元已出队,您需要在created_at
内更新数据源数组
cellForRowAt
和
cell.textField.addTarget(self, action: #selector(textFieldDidChange(_:)), for: .editingChanged)
cell.textField.indexPath = indexPath
创建此类并将其分配给文本字段
@objc func textFieldDidChange(_ textField: CustomTexf) {
let index = textField.indexPath
textFields[index.section][index.row] = textField.text!
}