swiftuitableviewviewwillappear

ViewWillAppear on UITableViewCell?


Is there any way to perform something like ViewWillAppear on UITableViewCell?

UITableViewDelegate methods (like willDisplayCell) only works when cells appear by scrolling.

In my situation, I need to detect cell appearance in a situation like user moves to another Tab and gets back to the UITableView.

I was able to solve the my problem using indexPathsForVisibleRows method but this doesn't seem to be a smart way of doing it.


Solution

  • Yes. you have to use awakeFromNib meyhod inside the m file. this method is always call first.

    -(void)awakeFromNib{
    
    }
    

    if visible cell not load then you have to reload your tableview.

     tableView.reloadData()
    

    Hope it helps you.