Reputation: 1584
I'm currently posting a NSNotification that the cell is listening for if the tableview starts scrolling and when it stops scrolling. Is this the right/most efficient approach?
* UPDATE*
Apparently this wasn't clear enough. I'm not trying to inform the tableview that it's scrolling. I'm using this:
- (void )scrollViewDidScroll: (UIScrollView *)scrollView {
// How should I tell all of my tableview cells that we scrolled.
[[NSNotificationCenter defaultCenter] postNotificationName:@"scrolled" object:self];
}
And then when the cell is created -
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pauseVideo:) name:@"scrolled" object:nil];
And then posting a notification that each allocated cell is listening for. Is this the best approach?
Upvotes: 0
Views: 489
Reputation: 3721
I think for scrolling performance it is better to use scrollViewWillBeginDragging
, because it is called once. And in this handler you can just iterate through visible cells and stop player in each of them.
Upvotes: 1
Reputation: 425
A UITableView inherits from UIScrollView. So, there are delegate methods on the UIScrollView which is contained inside the TableView. You should adapt those methods inside your controller.
UPDATED:
Try adapting this:
tableView:didEndDisplayingCell:forRowAtIndexPath:
Upvotes: 2