asif saifi asif saifi - 5 months ago 44
iOS Question

UITextField and UITextView disappears after scrolling in tableview?

I am using UItextfield and UItextview and when I type something inside textview and textfield and do scrolling inside tableview.The data will disappear and sometimes data inside textfield and textview got repeat.


func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell

var cell = table_view_one.dequeueReusableCell(withIdentifier: "first_cell", for: indexPath) as! first_cell
cell.add_new_btn.setImage(UIImage(named:"close"), for: .normal)
cell.delegate = self return cell

UITextField and UITextView disappears after scrolling in tableview

Answer Source

You can create an array containing the text written in textfield. Firstly, Initiate array with capacity of number of cell and add empty string to each index.

Then, as an when you write in any textfield in textFieldDidEndEditing save that text to array at proper index by getting cell index from point (textfield).

In cellForRow just assign the values of array according to indexPath.row

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download