user3143691
user3143691

Reputation: 1553

Input of textField in TableViewCell disappeared after scrolling

I have a UITableView with 12 cells. In the cells there is an UITextField. When I write something into the textfield and scroll down the input is moved to another cell or is removed.

Upvotes: 0

Views: 1034

Answers (1)

user3143691
user3143691

Reputation: 1553

UPDATE:

I've solved it on my own.

First I created a string array and put tags to the textfields in the "cellForRowAtIndexPath" delegate. Then every time the player finished the editing of the text I save it to the string array.

    func textFieldDidEndEditing(textField: UITextField) {

    let currentTag = textField.tag
    self.playerNamedFinishedEdit[currentTag] = textField.text!
}

In the "cellForRowAtIndexPath" i added the following code and all works fine now.

    cell.playerTextField.text = self.playerNamedFinishedEdit[indexPath.row]

Upvotes: 3

Related Questions