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.
I'm not sure whether this will work for you as you want to do something on tab change as well otherwise it will work.
I know I am answering too late, but I am answering to help others who view this post.
So you can try this: (Objective-C)
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell
forRowAtIndexPath:(NSIndexPath *)indexPath {
// Do what ever you want
}
(Swift)
func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
// Do what ever you want
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With