1

In my app I have a custom tableViewCell,

I also have a View Controller with a tableView, where I display custom tableViewCells.

Is there a method (ViewController method or TableViewCell method) which fires when tableViewCell goes off the screen, I need to make some Core Data updates in it for my cell.

(I need to know the method, because I need to update Core Data value of Timer() in my tableViewCell when it goes off the screen.)

Adelmaer
  • 2,209
  • 3
  • 22
  • 45

3 Answers3

3

following tableview delegate used to detect cell end displaying :: tableView:didEndDisplayingCell:forRowAtIndexPath:

func tableView(_ tableView: UITableView, didEndDisplaying cell: UITableViewCell, forRowAt indexPath: IndexPath)

above method fire when cell removed from tableview or cell ending its diplaying.

Dhaval Patel
  • 716
  • 1
  • 10
  • 26
2

You can use tableView:didEndDisplayingCell:forRowAtIndexPath: deleaget method of UITableView

func tableView(_ tableView: UITableView, didEndDisplaying cell: UITableViewCell, forRowAt indexPath: IndexPath) {

    }

Here please note that when you reload tableview or cell, the cell that is being removed will trigger this method. So implement additional logic inside this method to handle that situation.

Aravind A R
  • 2,674
  • 1
  • 15
  • 25
1

there is a tableView(_:didEndDisplaying:forRowAt:) delegate method: https://developer.apple.com/documentation/uikit/uitableviewdelegate/1614870-tableview

André Slotta
  • 13,774
  • 2
  • 22
  • 34
  • `Use this method to detect when a cell is removed from a table view, as opposed to monitoring the view itself to see when it appears or disappears.` Looks like this might do a different thing. – Fogmeister Jun 08 '17 at 11:38