简体   繁体   中英

The content of UItableViewCell in not updating swift4

I have a custom uitableviewcell called customContactsTableViewCell. I am trying to use this code to update the uitableviewCell content

let cell1 = self.contactsTableView.dequeueReusableCell(withIdentifier: "contacts", for: IndexPath.init(row: index, section: 0)) as! customContactsTableViewCell
cell1.cellView.image = statusFinal.1
self.contactsTableView.reloadData()

But nothing happens. no errors and the cellview is not updated

If you are created your tableview through Storyboard just go to your tableview and set cell custom class to customContactsTableViewCell And you'r cell identifier should be contacts if everything is already setup like this, then just check your these lines.

cell1.cellView.image = statusFinal.1
self.contactsTableView.reloadData()

After reloadData it redraw tableview again and setup data in it through this tableview Delegate function.

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
       /// your code
    }

It will again update your data with old data, Just save this data statusFinal.1 in your data model and then whenever you require reload, it will get update through updated data. Hope so you got the point, if need more info let me know.

Try:

let cell1 = tableView.cellForRow(at: IndexPath(row: index, section: 0)) as! customContactsTableViewCell
cell1.cellView.image = statusFinal.1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM